API Reference#
Module contents#
This package is designed for the study of metrology and arithmetic of natural sexagesimal numbers used by Babylonian scribes and their apprentices in antiquity.
Inpired by the arithmetic and metrological parts of Baptiste Mélès’ MesoCalc, it aims to bring this type of calculation to Python programming and to the command line as a calculator.
- class BabN(value: int | str | list[int] | tuple[int, int, int, int])#
Bases:
objectThis class implements a sexagesimal representation of the natural numbers and their basic arithmetic operations, especially in their “floating” version, as performed by Babylonian scribes. Hence the name.
Class attributes:#
- title:
Describe the type of object
- type title:
str
- sep:
separator for string representation (default: “:”)
- type sep:
str, (default: “:”)
- fill:
if True writes: “01.33.07” instead of “1.33.7”
- type fill:
bool, (default: False)
- rdigits:
approximate number of sexagesimal digits for some results
- type rdigits:
int, (default: 6:)
- floatmult:
If True, multiplication result is floating
- type floatmult:
bool, (default: False)
- database:
path to SQLite3 database of regular numbers providing:
regular: TEXT, regular number e.g. 01:18:43:55:12len: INTEGER, its length e.g. 5 for 01:18:43:55:12seecreateDB.pyorhamming.pyfor how to generate it- type database:
str, (default: “regular.db3”)
Instance attributes:#
- dec:
decimal versión of number (ex: 405 for sexagesimal “6:45”)
- type dec:
int
- list:
list of sexagesimal digits of number (ex: [6, 45] for 405 or “6:45”)
- type list:
list
- isreg:
True if number is regular (only contains 2, 3, 5 as divisors)
- type isreg:
bool
- factors:
tuple with the powers of 2, 3, 5 and the remainder
- type factors:
tuple
jccsvq fecit, 2005. Public domain.
Operators#
This class overloads arithmetic and logical operators allowing arithmetic operations and comparisons to be performed between members of the class and externally with integers. Comparing with any other object type will raise
NotImplementedError.Initialize a new Babylonian number (BabN).
This constructor acts as a robust gateway for sexagesimal data. It normalizes input values, enforces the non-negative constraint of Babylonian mathematics, and protects against improper metrological mixing.
- param value:
The source data for the number. Supported formats:
int | float: Absolute integer value.
str: Sexagesimal digits separated by non-numeric characters (e.g., “1:20”, “1.20”).
list: Coefficients of the sexagesimal polynomial. Values > 59 are automatically normalized (carry-over).
tuple: A 4-element factor tuple (i, j, k, x) representing \(2^i \cdot 3^j \cdot 5^k \cdot x\).
- type value:
int | str | list | tuple
- raises ValueError:
If the input string contains no digits, a tuple does not have 4 elements, or factors are invalid.
- raises TypeError:
If an unsupported type is passed, or if a metrological unit (e.g., Blen, Bwei) is found inside a list.
Note
Normalization Logic: If a list is provided as
[1, 125], it is treated as \(1 \cdot 60^1 + 125 \cdot 60^0 = 185\), which normalizes to[3, 5](3:05).Warning
To maintain historical rigor, all negative inputs are converted to their absolute value.
- classmethod create_new(data: int | str | list[int] | tuple[int, int, int, int]) BabN#
Class method that returns a new instance.
- Parameters:
data (_type_) – _description_
- Returns:
resultant object
- Return type:
“BabN”
- static _calculate_factors(n: int) tuple[int, int, int, int]#
Obtains \(i, j, k, x\) such that \(2^i \cdot 3^j \cdot 5^k \cdot x = n\)
- Parameters:
n (int) – decimal integer
- Returns:
tuple (i, j, k, x)
- Return type:
tuple[int, int, int, int]
- static _to_decimal(s_list: list[int]) int#
Convert a sexagesimal list to a decimal integer (BigInt).
- Parameters:
s_list (list[int]) – list of sexagesimal digits
- Returns:
equivalent decimal integer
- Return type:
int
- static _to_sexagesimal(n: int) list[int]#
Convert a decimal integer to its sexagesimal list representation.
- Parameters:
n (int) – decimal integer to convert
- Returns:
resulting sexagesimal list
- Return type:
list[int]
- static genDB(dbname: str) None#
Generates a sqlite3 database of regular numbers up to 20 sexagesimal digits
- Dbname:
database path and name
- _ensure_babn(other: object) BabN#
Internal helper to normalize types before operating.
- Parameters:
other (object) – operand
- Returns:
BabN object
- Return type:
- cbrt() BabN#
Returns BabN object with approximate floating cube root
- Returns:
approximate floating cube root
- Return type:
- cuneiform(alter: bool = False, stroke: bool = False) str#
Cuneiform version of sexagesimal number
Requires Noto Sans Cuneiform font or similar to be present in your system. This method uses U+2009 Thin Space Unicode Characters
- Parameters:
obj (Any) – BabN object or string to be converted
alter (bool, optional) – alternate version of some signs, defaults to False
stroke (bool, optional) – strike out empty space (sexagesimal digit zero), defaults to False
- Returns:
cuneiform string
- Return type:
str
- dist(n: str | int | _SpecialForm) int#
Estimates a certain “pseudo-distance” between two sexagesimal numbers.
The objective is, given a non-regular number, to select the regular number that is closest to it from a list. Since these are floating-point numbers, this pseudo-distance must be based on the similarity of the most significant sexagesimal digits, so that 7 is “close” to 6:59:54:14:24 (decimals 7 and 90699264).
- Parameters:
n (str | int | type) – may be an integer, formated string (ex: “1:2:3”), a list (ex., [1, 12, 23]) or another BabN object.
- Returns:
pseudo-distance
- Return type:
int
- explain() None#
Explains number; print out basic information about the object.
- f() Self#
Returns BabN object with the floating part of the number (mantissa), i.e., removes any trailing sexagesimal zero, ex.: 4:42:0:0 -> 4:42
- float() Self#
Returns BabN object with the floating part of the number (mantissa), i.e., removes any trailing sexagesimal zero, ex.: 4:42:0:0 -> 4:42
- head(d: int = 1) BabN#
Returns the BabN object with the first d digits at most from self
- Parameters:
d (int, optional) – Number of digits to return, defaults to 1
- Returns:
d most significant sexagesimal digits of self
- Return type:
- inv(digits: int = 4) Self | None#
Returns BabN object with approximate inverse of the number, i.e., a * a.inv() is approximately a power of 60
- Parameters:
digits (int, optional) – the intended number of digits to return, defaults to 4
- Returns:
_description_
- Return type:
“BabN” | None
- len() int#
Returns the number of sexagesimal digits of the number as int
- Returns:
number of sexagesimal digits of the number as int
- Return type:
int
- multable(pral: bool = True, sep: str = ':', fill: bool = False, cuneiform: bool = False, stroke: bool = False, floating: bool = False, indices: List[int] = None, echo: bool = True) List[str] | None#
Displays the multiplication table for the current number.
Following Babylonian tradition, the table includes the ‘principal’ multipliers (1 to 20, then 30, 40, 50) or the full range (1 to 59).
- Parameters:
pral (bool) – If True, prints principal numbers (1-20, 30, 40, 50). If False, prints 1 to 59. Defaults to True.
sep (str) – Separator for sexagesimal digits. Defaults to “:”.
fill (bool) – If True, adds leading zeros to sexagesimal digits <= 9.
cuneiform (bool) – If True, outputs the table in Unicode Cuneiform.
stroke (bool) – If True, strikes out empty spaces (zeroes) in cuneiform.
floating (bool) – If True, results are treated as sexagesimal floating point.
indices (list[ints]) – print table only for these values. Defaults to None.
echo (bool) – if False return list of marldown lines instead of printing them. Defaults to True.
- Returns:
List of strings with markdown table
- Return type:
List[str] | None
- multable_nb(*arg, **kwargs)#
Displays the multiplication table in a Jupyter Notebook using Markdown.
- Parameters:
arg – Positional arguments for multable.
kwargs – Keyword arguments for multable.
- rec() Self | None#
Returns the reciprocal of the BabN object using the factorization method.
- round(d: int) BabN#
Returns BabN object rounded to d sexagesimal digits
- Parameters:
d (int) – Number of digits to return
- Returns:
number rounded to d sexagesimal digits
- Return type:
- searchreg(minn: str | int, maxn: str | int, limdigits: int = 6, prt: bool = False) BabN#
Search database for regulars between sexagesimals minn y maxn. Returns BabN object with the closest regular found.
- Parameters:
minn (str | int) – and maxn: must be sexagesimal strings using “:” separator
maxn (str | int) – and maxn: must be sexagesimal strings using “:” separator
limdigits (int, optional) – max regular digits number, defaults to 6
prt (bool, optional) – print list of found regulars, defaults to False
- Returns:
closest regular found as BabN object
- Return type:
- sqrt() BabN#
Returns BabN object with approximate floating square root
- Returns:
approximate floating square root
- Return type:
- tail(d: int = 1) BabN#
Returns the BabN object with the last d digits of itself at most
- Parameters:
d (int, optional) – Number of digits to return, defaults to 1
- Returns:
d less significant sexagesimal digits of self
- Return type:
- to_cunei(alter: bool = False, stroke: bool = False) str#
Cuneiform version of sexagesimal number
Requires Noto Sans Cuneiform font or similar to be present in your system. This method uses U+2009 Thin Space Unicode Characters
- Parameters:
obj (Any) – BabN object or string to be converted
alter (bool, optional) – alternate version of some signs, defaults to False
stroke (bool, optional) – strike out empty space (sexagesimal digit zero), defaults to False
- Returns:
cuneiform string
- Return type:
str
- trim(d: int) BabN#
Returns BabN object corresponding to the first d sexagesimal digits
- Parameters:
d (int) – Number of digits to retain
- Returns:
_description_
- Return type:
- database: str = 'regular.db3'#
- property dec#
Getter
- property factors: tuple[int, int, int, int]#
Getter. Calculate the factors only when requested (Lazy).
- Returns:
i, j, k, x such that self.dec = 2^i * 3^j * 5^k * x
- Return type:
tuple[int, int, int, int]
- fill: bool = False#
- floatmult: bool = False#
- property isreg: bool#
Getter (Lazy)
- property list#
Getter
- rdigits: int = 6#
- sep: str = ':'#
- title: str = 'Sexagesimal number'#
- class Bbri(x: int | str | float)#
Bases:
MesoMThis class implement Non-Place-Value System arithmetic for Old Babylonian Period counting bricks in “sar-b” units (720 bricks):
GAN2 <-100- sar <-60- gin2 <-180- še
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- vol(nalb: float = 1.0) Bvol#
Returns the volume corresponding to a number of bricks based on their Nalbanum. 1 sar volume for 720 bricks if nalb is 1
- Parameters:
nalb (float, optional) – nalbanum in decimal e.g. 7.20 for type 2 bricks, defaults to 1.0
- Returns:
equivalent volume
- Return type:
Brick type
Nalb. (dec.)
Nalb. (sex.)
1
9.00
9
1a
8.33
8:20
2
7.20
7:12
3
5.40
5:24
4
5.00
5
5
4.80
4:48
7
3.33
3:20
8
2.70
2:42
9
2.25
2:15
10
1.875
1:52:30
11
1.20
1:12
12
1.00
1
- sex_threshold = 3#
- siu: str = 'bricks'#
- siv: float = 0.06666666666666667#
- title: str = 'Babylonian brick count'#
- trmodel: str = 'Bsur'#
- ubase: int = 1#
- class Bcap(x: int | str | float)#
Bases:
MesoMThis class implement Non-Place-Value System arithmetic for Old Babylonian Period capacity units:
gur <-5- bariga <-6- ban2 <-10- sila3 <-60- gin2 <-180- še
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- vol() Bvol | None#
Convert capacity to volume measurement
- Returns:
volume measurement
- Return type:
“Bvol” | None
- sex_threshold = 4#
- siu: str = 'litres'#
- siv: float = 9.259259259259259e-05#
- title: str = 'Babylonian capacity measurement'#
- trmodel: str = 'Bcap'#
- ubase: int = 1#
- class Blen(x: int | str | float)#
Bases:
MesoMThis class implement Non-Place-Value System arithmetic for Old Babylonian Period length units
danna <-30- UŠ <-60- ninda <-12- kuš3 <-30- šu-si
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- sex_threshold = 5#
- siu: str = 'meters'#
- siv: float = 0.016666666666666666#
- title: str = 'Babylonian length measurement'#
- trmodel: str = 'Blen'#
- ubase: int = 2#
- class Bsur(x: int | str | float)#
Bases:
MesoMThis class implement Non-Place-Value System arithmetic for Old Babylonian Period surface units:
GAN2 <-100- sar <-60- gin2 <-180- še
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- sex_threshold = 3#
- siu: str = 'square meters'#
- siv: float = 0.003333333333333333#
- title: str = 'Babylonian surface measurement'#
- trmodel: str = 'Bsur'#
- ubase: int = 1#
- class BsyC(x: int | str | float)#
Bases:
_MesoMThis class implement Non-Place-Value System arithmetic for Babylonian System-C (Common) numeration
u <-10- diš
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- siu: str = '#'#
- siv: float = 1#
- system_type: str = 'C'#
- title: str = 'Babylonian System S to count objects'#
- ubase: int = 0#
- class BsyG(x: int | str | float)#
Bases:
_MesoMThis class implement Non-Place-Value System arithmetic for Babylonian System-G (GAN2) numeration
šar2-gal <-6- šar’u <-10- šar2 <-6- bur’u <-10- bur3 <-3- eše3 <-6- iku
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- dic_cfact = {'bur': 18, 'buru': 180, 'ese': 6, 'iku': 1, 'sar': 1080, 'sargal': 64800, 'saru': 10800}#
- siu: str = '#'#
- siv: float = 1#
- system_type: str = 'G'#
- title: str = 'Babylonian System G to count objects'#
- ubase: int = 0#
- class BsyK(x: int | str | float)#
Bases:
_MesoMThis class implement Non-Place-Value System arithmetic for Babylonian System-SKL (Sumerian King List) numeration
šar2-gal <-6- šar’u <-10- šar2 <-6- geš’u <-10- geš <-6- u <-10- diš
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- dic_cfact = {'dis': 1, 'ges': 60, 'gesu': 600, 'sar': 3600, 'sargal': 216000, 'saru': 36000, 'u': 10}#
- siu: str = '#'#
- siv: float = 1#
- system_type: str = 'K'#
- title: str = 'Babylonian System SKL to count years'#
- ubase: int = 0#
- class BsyS(x: int | str | float)#
Bases:
_MesoMThis class implement Non-Place-Value System arithmetic for Babylonian System-S (Sexagesimal) numeration
šar2-gal <-6- šar’u <-10- šar2 <-6- geš’u <-10- geš <-6- u <-10- aš
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- dic_cfact = {'as': 1, 'ges': 60, 'gesu': 600, 'sar': 3600, 'sargal': 216000, 'saru': 36000, 'u': 10}#
- siu: str = '#'#
- siv: float = 1#
- system_type: str = 'S'#
- title: str = 'Babylonian System S to count objects'#
- ubase: int = 0#
- class Bvol(x: int | str | float)#
Bases:
MesoMThis class implement Non-Place-Value System arithmetic for Old Babylonian Period volume units:
GAN2 <-100- sar <-60- gin2 <-180- še
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- bricks(nalb: float = 1.0) Bbri#
Returns the volume in number of bricks equivalent based on their “Nalbanum.” 720 for 1 sar volume if nalb is 1.
- Parameters:
nalb (float, optional) – nalbanum in decimal e.g. 7.20 for type 2 bricks, defaults to 1.0
- Returns:
volume in bricks equivalent
- Return type:
“Bbri”
Brick type
Nalb. (dec.)
Nalb. (sex.)
1
9.00
9
1a
8.33
8:20
2
7.20
7:12
3
5.40
5:24
4
5.00
5
5
4.80
4:48
7
3.33
3:20
8
2.70
2:42
9
2.25
2:15
10
1.875
1:52:30
11
1.20
1:12
12
1.00
1
- cap()#
Convert volume to capacity measurement
- sex_threshold = 3#
- siu: str = 'cube meters'#
- siv: float = 0.0016666666666666666#
- title: str = 'Babylonian volume measurement'#
- trmodel: str = 'Bsur'#
- ubase: int = 1#
- class Bwei(x: int | str | float)#
Bases:
MesoMThis class implement Non-Place-Value System arithmetic for Old Babylonian Period weight units:
gu2 <-60- ma-na <-60- gin2 <-180- še
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- sex_threshold = 3#
- siu: str = 'kilograms'#
- siv: float = 4.6296296296296294e-05#
- title: str = 'Babylonian weight measurement'#
- trmodel: str = 'Bwei'#
- ubase: int = 1#
Submodules#
mesomath.babn module#
This module implements class Babn for sexagesimal representation of the natural numbers and their basic arithmetic operations, especially in their “floating” version, as performed by Babylonian scribes. Hence the name.
mesomath.hamming module#
Generation of Hamming numbers (Regular numbers).#
This module provides functions to generate Hamming numbers, also known as Regular numbers. These are numbers whose prime factors are limited to 2, 3, and 5.
with
The implementation uses the cyclic generator (method #2) adapted from Rosetta Code. The Rosetta Code algorithm is a very elegant and functional implementation (lazy evaluation style), but its brevity makes it cryptic. It uses generators and the tee function from itertools to create self-feeding data streams, emulating a recursive data structure.
Output Formats#
The module can generate Hamming numbers in three formats:
Database Generation#
To create the regular.db3 database required by the BabN class,
you can pipe the script output directly into the sqlite3 utility:
$ python3 hamming.py | sqlite3 regular.db3
Note
All output is directed to stdout by default.
- Author:
jccsvq
- Date:
2025
- genCSV(maxn: int, sep: str = ',') None#
Generates csv table of regular numbers and reciprocals
genCSV(80000) takes a few seconds! Writes to stdin.
- Parameters:
maxn (int) – write the table up to this value
sep (str, optional) – csv field separator, defaults to “,”
- genSQL(maxn: int) None#
Generates list or regular numbers in sqlite3 SQL format
- Parameters:
maxn (int) – decimal int, write the table up to this value
- hamming(a: int, b: int | None = None) list[int]#
Generates a list of Hamming’s numbers from a to b if b is not None, otherwise return a list containig the a-th hamming number only
- Parameters:
a (int) – starting number
b (int | None, optional) – list ending number, defaults to None
- Returns:
list of Hamming’s numbers
- Return type:
list[int]
mesomath.npvs module#
This module implements classes for Non-Place-Value numeration system and related arithmetic. Intended for Mesopotamian metrological systems, but class Npvs is of general use.
class Npvs: Generic class inspired in Imperial Units System lengths
class _MesoM: Specializes the Npvs class to handle Mesopotamian counting systems.
class BsyC: Babylonian System C
class BsyG: Babylonian System G
class BsyS: Babylonian System S
class BsyK: Babylonian System K
class MesoM: Specializes the Npvs class to handle Mesopotamian measurements.
class Blen: Babylonian length system
class Bsur: Babylonian surface system
class Bvol: Babylonian volume system
class Bcap: Babylonian capacity system
class Bwei: Babylonian weight system
class Bbri: Babylonian brick counting system
- class MesoM(x: int | str | float)#
Bases:
_MesoMThis class complements the _MesoN class by allowing you to express unit coefficients in measurements using the S and G systems as appropriate. It introduces the sexsys attribute and enhances the __repr__ method.
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- classmethod _draw_colophon(subtotal, linecount, **kwargs)#
Internal helper to generate the administrative closing (Shu-nigin).
- classmethod lookup(value: str | int, ubase: int = None, strict: bool = False, width: int = 20, fractions: int = -1, academic: bool = False, verbose: bool = False, translit: bool = False, cuneiform: bool = False)#
Performs a reverse metrological search. Given an abstract sexagesimal number, it lists all possible physical measurements within the class that correspond to that number at different orders of magnitude.
- Parameters:
value (str | int) – The abstract sexagesimal value to look up (e.g., ‘20’ or 20).
ubase (int, optional) – Index of the reference unit for the abstract value. Defaults to cls.ubase.
strict (bool, optional) – If True, only matches where the sexagesimal representation is identical.
width (int, optional) – Character width for the measurement column in the output table.
fractions (int, optional) – Number of fractional parts to show. -1 for default representation.
academic (bool, optional) – Use academic notation (e.g., using ‘;’ for sexagesimal fractions).
verbose (bool, optional) – If True, provides detailed info including SI equivalents.
translit (bool, optional) – If True, displays the measurement in Nippur-style transliteration.
cuneiform (bool, optional) – If True, displays both measurement and abstract value in Unicode cuneiform.
- classmethod metro_generator(mmin: str | int, mmax: str | int | list, step: str | int | list, verbose: bool = False, ubase: int | None = None, width: int = 20, fractions: int = -1, actual: bool = False, translit: bool = False, cuneiform: bool = False, subst: str = '', incipit: bool = False, **kwargs)#
Generator that yields formatted metrological strings line by line.
- Parameters:
mmin (str | int) – Initial value (e.g., ‘1 ninda’ or integer)
mmax (str | int) – Final value
step (str | int) – Increment
verbose (bool, optional) – If it is True, it returns the floating metrological value, defaults to False
ubase (int, optional) – force ubase unit, defaults to None
width (int, optional) – output width, defaults to 20
fractions (int, optional) – Use fractions if 1 and add 1/6 if 2, defaults to -1 (no fractions)
actual (bool, optional) – use academic unit names
echo (bool, optional) – If True, prints the table to stdout. If False, only returns the list.
translit (bool, optional) – If True, prints the table in transliteration.
cuneiform (bool, optional) – If True, prints the table in cuneiform.
subst (str, optional) – add substance glyph to line
incipit (bool, optional) – write subst on first line only, defaults to False
- Yields:
str (Each row of the table)
- classmethod metrocsv(*args, **kwargs)#
Exports the results of metrolist to a CSV file. Accepts the same arguments as metro_generator and some that are specific to it.
- Parameters:
file (str, optional) – output filename base, defaults to ‘output’
- classmethod metrohtml(*args, **kwargs)#
Exports the results of metrolist to a basic HTML table. Accepts the same arguments as metro_generator and some that are specific to it.
- Parameters:
file (str, optional) – output filename base, optional
caption (str, optional) – table caption, optional
full_page (bool, optional) – write a complete test HTML page instead of just the table, defaults to False
- Returns:
HTML output
- Return type:
str
- classmethod metrolatex(*args, **kwargs)#
_summary_
- Returns:
_description_
- Return type:
_type_
- classmethod metrolist(*args, **kwargs)#
Generate a list of metrological values for the current class. Now supports multi-range sections by passing lists to mmax and step. Accepts the same arguments as metro_generator and some that are specific to it.
- classmethod metronotebook(*args, **kwargs)#
Wrapper for .metrohtml() to use in notebook environments. Uses the same options plus a special one of its own.
- Parameters:
details (bool, optional) – collapse the output in <details> tag, usefull for long tables, defaults to False
- __repr__(actual: bool = False) str#
Academic representation: System C for small units, System S for large units or overflow values (>60).
- Parameters:
actual (bool, optional) – use academic names, defaults to False
- Returns:
object representation
- Return type:
str
- _transliterate(cuneiform: bool = False, postprocess: bool = True) str#
Return the metrological transliteration or cuneiform representation of the object.
This method performs a greedy decomposition of ‘self.dec’ into values corresponding to graphemes present in the Old Babylonian metrological lists published by C. Proust (2009). The resulting tokens are concatenated and optionally re-analyzed to regroup identical units and recalculate coefficients, ensuring historical accuracy in the final string.
- Parameters:
cuneiform (bool, optional) – If True, converts the transliterated tokens into their corresponding cuneiform Unicode characters.
postprocess (bool, optional) – If True, performs a secondary pass to aggregate repetitive minor units (e.g., ‘še’ grains) into single blocks.
- Raises:
AttributeError – Raised if the object’s ‘trmodel’ is not a valid Proust-based metrological model (Blen, Bsur, Bwei, Bcap).
- Returns:
A string containing the historical transliteration or cuneiform signs.
- Return type:
str
- labor_cost(work_man: str | int) float#
Calculate the number of workdays or man-days required for the task.
- Parameters:
work_man (str | int) – work done in a day by worker
- Returns:
number of workdays or man-days
- Return type:
float
- prtf(onesixth: bool = False, actual: bool = False) str#
Print metrological values using fractions Revised version for MesoMath v2.0.0
- Parameters:
onesixth (bool, optional) – include 1/6 fractions, defaults to False
actual (bool, optional) – use academic unit names, defaults to False
- Returns:
output string
- Return type:
str
- rations(work_man: str | int, wage: str | int) Bcap#
Calculate the cost of the work when payment is in capacity units
- Parameters:
work_man (str | int) – work done in a day by worker (magnitude of current class)
wage (str | int) – dayly payment for worker (grain, beer, etc. in capacity units)
- Returns:
total amount to pay
- Return type:
- silver_payments(work_man: str | int, wage: str | int) Bwei#
Calculate the cost of the work when payment is in silver (weight).
- Parameters:
work_man (str | int) – work done in a day by worker (magnitude of current class)
wage (str | int) – dayly payment for worker (in silver weight units, e.g., ‘8 se’)
- Returns:
total amount of silver to pay
- Return type:
- to_cunei(**kwargs) str#
INTERFAZ PARA CLASES METROLÓGICAS (Bcap, Bsur, Bwei, etc.). Usa descomposición por unidades y fracciones.
- class Npvs(x: int | str)#
Bases:
object- This class implement Non-Place-Value System arithmetic
Example is taken from Imperial length units:
league <-3- mile <-8- furlong <-10- chain <-22- yard <-3- foot <-3- hand <-4- inch
Class Atributes:#
- title:
Definition of the object
- uname:
Unit names
- ufact:
Factor between units
- aname:
Actual or academic unit names
- cfact:
Factor with the smallest unit
- siv:
S.I. value of the smallest unit
- siu:
S.I. unit name
- prtsex:
Printing measurements in sexagesimal (default: False)
Instance Attributes:#
- dec:
Decimal value of measurement in terms of the smallest unit
- list:
List of values per unit
Operators#
This class overloads arithmetic and logical operators allowing arithmetic operations and comparisons to be performed between members of the class. Comparison with other objects raises
NotImplementedError.jccsvq fecit, 2005. Public domain.
Class constructor
- param x:
The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- type x:
int | str
- classmethod from_si(val: float) object#
Converts SI measure into object.
- Parameters:
val (float) – SI value
- Returns:
Object with corresponding SI value
- Return type:
object
- classmethod scheme(actual: bool = False) list#
Returns list with the unit names separated by the corresponding factors
- Parameters:
actual (bool, optional) – Uses actual or academic unit names if True, defaults to False
- Returns:
list with the unit names separated by the corresponding factors
- Return type:
Example
>>> print(*Npvs.scheme(Npvs)) lea <-3- mi <-8- fur <-10- ch <-22- yd <-3- ft <-3- hh <-4- in
>>> print(*Npvs.scheme(Npvs,actual=1)) league <-3- mile <-8- furlong <-10- chain <-22- yard <-3- foot <-3- hand <-4- inch
- SI() str#
Returns formated string with the equivalent in SI units
- Returns:
formated string with the equivalent in SI units
- Return type:
str
- __add__(other: Self) Self#
Overloads
+operator: returns object with the sum of operands- Parameters:
other (Self) – operand
- Returns:
object with the sum of operands
- Return type:
Self
- __eq__(other: Self) bool#
Overloads
==operator- Parameters:
other (Self) – another Npvs object
- Raises:
NotImplementedError – if not Self object
- Returns:
comparison result
- Return type:
bool
- __ge__(other: Self) bool#
Overloads
>=operator- Parameters:
other (Self) – another Npvs object
- Raises:
NotImplementedError – if not Self object
- Returns:
comparison result
- Return type:
bool
- __gt__(other: Self) bool#
Overloads
>operator- Parameters:
other (Self) – another Npvs object
- Raises:
NotImplementedError – if not Self object
- Returns:
comparison result
- Return type:
bool
- __hash__()#
Returns hash value of the instance
- __init__(x: int | str) None#
Class constructor
- Parameters:
x (int | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- __int__()#
Converts instance to int
- __le__(other: Self) bool#
Overloads
<=operator- Parameters:
other (Self) – another Npvs object
- Raises:
NotImplementedError – if not Self object
- Returns:
comparison result
- Return type:
bool
- __lt__(other: Self) bool#
Overloads
<operator- Parameters:
other (Self) – another Npvs object
- Raises:
NotImplementedError – if not Self object
- Returns:
comparison result
- Return type:
bool
- __mul__(other: int | float) Self#
Overloads
*operator: returns object with the operands product- Parameters:
other (int | float) – operand
- Returns:
object with the operands product
- Return type:
Self
- __ne__(other: Self) bool#
Overloads
!=operator- Parameters:
other (Self) – another Npvs object
- Raises:
NotImplementedError – if not Self object
- Returns:
comparison result
- Return type:
bool
- __repr__() str#
Returns string representation of object
- __rmul__(other: int) Self#
Overloads
*operator: returns object with the operands product- Parameters:
other (int | float) – operand
- Returns:
object with the operands product
- Return type:
Self
- __sub__(other: Self) Self#
Overloads
-operator: returns object with the absolute difference of operands- Parameters:
other (Self) – operand
- Returns:
object with the absolute difference of operands
- Return type:
Self
- __truediv__(other: int | float) Self#
Overloads
/operator: returns object with the operands quotient- Parameters:
other (int | float) – operand
- Returns:
object with the operands quotient
- Return type:
Self
- dec2un(x: int) list#
Converts the decimal integer n to a list of integers, such that, for example, 1001 (inches) becomes
[1, 1, 2, 5, 1, 0, 0, 0], which means that 1001 inches equals: 1 chain 5 yards 2 feet 1 hand 1 inch.- Parameters:
x (int) – input decimal integer
- Returns:
list of unit coefficients
- Return type:
- si() float#
Returns the numeric equivalent in SI units
- Returns:
numeric equivalent in SI units
- Return type:
float
- __weakref__#
list of weak references to the object
- property dec#
Getter
- property list#
Getter
- class _MesoM(x: int | str | float)#
Bases:
NpvsSpecializes the Npvs class to handle Mesopotamian measurements.
Introduces the .sex(), .metval() and .explain() methods and the .prtsex attribute. Modifies __repr__()
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- classmethod cname() list#
Return list of unit cuneiform glyphs
- Returns:
list of unit cuneiform glyphs
- Return type:
- classmethod scheme(actual: bool = False, cuneiform: bool = False) list#
Factor diagram for MesoMath.
- Parameters:
actual (bool, optional) – uses actual or academic unit names if True, defaults to False
cuneiform (bool, optional) – write cuneiform glyphs if True, defaults to False
- Returns:
list with the unit names separated by the corresponding factors
- Return type:
- static _to_Cunei_base(val: int, system: str = 'S') str#
MATHEMATICAL ENGINE: Converts an integer to hierarchical NPVN glyphs. Does not add unit logograms or determinatives.
- Parameters:
val (int) – integer to convert
system (str, optional) – system to use C, S, G, K, defaults to “S”
- Returns:
cuneiform string representation of the integer
- Return type:
str
- __init__(x: int | str | float) None#
Class constructor
- Parameters:
x (int | float | str) – The parameter n can be an integer (sign is ignored) or a properly formatted string representing the value. See the tutorial
- __repr__(actual: bool = False) str#
Returns string representation of object.
- Parameters:
actual (bool, optional) – use academic names if True, defaults to False
- Returns:
object representation
- Return type:
str
- _get_decomposed_data(onesixth=False) tuple[<property object at 0x7c5632a3bec0>, <property object at 0x7c5632a3bec0>]#
Decompose the list of coefficients into two, one of them for fractional parts.
- abstract(r: int = None) BabN | None#
Return sexagesimal floating value of object
- Parameters:
r (int, optional) – index of reference unit in uname, defaults to 0
- Returns:
sexagesimal floating value of object
- Return type:
BabN | None
- explain() None#
Print some information about the object
- metval() BabN | None#
Returns metrological value of object
- Returns:
metrological value of object
- Return type:
BabN | None
- prtf(onesixth: bool = False, actual: bool = False) str#
Alternative to __repr__() to use the fractions 1/3, 1/2, 2/3, 5/6 of the units in the output. Modified version for v1.4.0: Integrates with MesoInterpreter’s scholastic systems (C and S)
- Onesixth:
Adds 1/6 to the previous set of fractions if True
- Actual:
if True, uses academic unit names on output
- pure_sex() str#
Returns the pure numerical representation without unit names.
- Returns:
pure numerical representation without unit names
- Return type:
str
- sex(r: int = 0) BabN | None#
Return sexagesimal floating value of object
- Parameters:
r (int, optional) – index of reference unit in uname, defaults to 0
- Returns:
sexagesimal floating value of object
- Return type:
BabN | None
- to_cunei(**kwargs) str#
INTERFACE FOR NUMERIC CLASSES (BsyS, BsyK, BsyG, BsyC). Adds historical disambiguation and determinants.
- property dec#
Getter
- property list#
Getter
- cmul(x: list[int]) list[int]#
Utility function. Returns list of cumulative products of the factor list x
- Example: cmul([4,3,3,22,10,8,3]) returns:
[1, 4, 12, 36, 792, 7920, 63360, 190080]
- normalize(st: str) str#
Converts aname’s to unit names and standardizes fractions.
- Parameters:
st (str) – input strig to be normalized
- Returns:
normalized string
- Return type:
str
- fdic0: Final[dict] = {3: (['2/3', '1/3'], [2, 1]), 5: ([''], []), 6: (['5/6', '2/3', '1/2', '1/3'], [5, 4, 3, 2]), 10: (['1/2'], [5]), 12: (['5/6', '2/3', '1/2', '1/3'], [10, 8, 6, 4]), 30: (['5/6', '2/3', '1/2', '1/3'], [25, 20, 15, 10]), 60: (['5/6', '2/3', '1/2', '1/3'], [50, 40, 30, 20]), 100: (['1/2'], [50]), 180: (['5/6', '2/3', '1/2', '1/3'], [150, 120, 90, 60])}#
Dictionary of principal fractions withouth 1/6
- fdic1: Final[dict] = {3: (['2/3', '1/3'], [2, 1]), 5: ([''], []), 6: (['5/6', '2/3', '1/2', '1/3', '1/6'], [5, 4, 3, 2, 1]), 10: (['1/2'], [5]), 12: (['5/6', '2/3', '1/2', '1/3', '1/6'], [10, 8, 6, 4, 2]), 30: (['5/6', '2/3', '1/2', '1/3', '1/6'], [25, 20, 15, 10, 5]), 60: (['5/6', '2/3', '1/2', '1/3', '1/6'], [50, 40, 30, 20, 10]), 100: (['1/2'], [50]), 180: (['5/6', '2/3', '1/2', '1/3', '1/6'], [150, 120, 90, 60, 30])}#
Dictionary of principal fractions including 1/6
mesomath.parser.interpreter module#
This module implements the Babylonian metrological expression interpreter based on PEG grammars.
The interpreter must be able to accept all 75 types of MesoMath output expressions so that they can be fed back as inputs.
- class MesoInterpreter(metrological_class: Any, sexagesimal_system: Any)#
Bases:
NodeVisitorMain interpreter for Mesopotamian metrological calculations. Coordinates between a metrological class (Length, Volume, etc.) and a sexagesimal system to resolve complex input strings.
Class constructor
- Parameters:
metrological_class – The main class (Blen, Bvol, etc.) providing unit names and factors.
sexagesimal_system – The sexagesimal system (BsyS and BsyG) for internal resolution.
- __init__(metrological_class: Any, sexagesimal_system: Any)#
Class constructor
- Parameters:
metrological_class – The main class (Blen, Bvol, etc.) providing unit names and factors.
sexagesimal_system – The sexagesimal system (BsyS and BsyG) for internal resolution.
- generic_visit(node, visited_children) Any#
Default fallback for node visitors.
- parse(text: str) float#
Normalizes the input text and parses it against the MESO_GRAMMAR. Returns the total accumulated value.
- visit_babn(node, visited_children) int#
Resolves BabN positional notation (e.g., 2:53) to its decimal value.
- visit_entry(node, visited_children) float#
Sums all individual measurements found in the string.
- visit_fractional(node, visited_children) float#
Maps fraction strings to their floating-point equivalents.
- visit_integer(node, visited_children) int#
Converts integer text to int.
- visit_measure(node, visited_children) int#
Resolves the final value of a measure by checking unit priorities: 1. Current metrological class (e.g., Blen factors). 2. Sexagesimal system associated with the class.
- visit_plus_frac(node, visited_children) float#
Returns the value of a fraction following a ‘+’ sign.
- visit_sexag(node, visited_children) float#
Handles parenthetical sexagesimal expressions by delegating to the SexagInterpreter.
- visit_unit_name(node, visited_children) str#
Returns the raw unit name.
- visit_value(node, visited_children) float#
Processes numerical values, including optional fractions (e.g., 5 + 1/2).
- class SexagInterpreter(sexsys: Any)#
Bases:
NodeVisitorInterpreter for the contents of sexagesimal parenthetical expressions. It resolves units based on a specific sexagesimal system (e.g., BsyS, BsyG).
Class constructor
- Parameters:
sexsys (Any) – sexagesimal system S or G
- __init__(sexsys: Any)#
Class constructor
- Parameters:
sexsys (Any) – sexagesimal system S or G
- generic_visit(node, visited_children)#
Default visitor for nodes without a specific visit method.
- visit_entry(node, visited_children)#
Sums all processed measurements within the parentheses.
- visit_measure(node, visited_children)#
Processes a single measurement unit and multiplies by its factor.
- visit_unit_name(node, visited_children)#
Returns the raw unit name string.
- visit_value(node, visited_children)#
Converts numerical text to float.
- MESO_GRAMMAR = '\n entry = (measure space)*\n measure = value space unit_name\n value = (sexag plus_frac?) / (babn plus_frac?) / (integer plus_frac?) / fractional\n \n sexag = "(" ~"[^)]+" ")"\n babn = ~r"[0-9]+(:[0-9]+)+"\n \n plus_frac = "+" fractional\n fractional = ~r"[1-5]/6" / ~"1/2" / ~"1/3" / ~"2/3" / ~"5/6"\n \n integer = ~r"[0-9]+"\n unit_name = ~r"[a-z1-3šś\\\'\\-]+"\n space = ~r"\\s*"\n'#
Main grammar used to parse complex metrological strings
- SEXAG_GRAMMAR = '\n entry = (measure space)*\n measure = value space unit_name\n value = integer / fractional\n integer = ~r"[0-9]+"\n fractional = ~r"[1235]/6" / ~"1/2" / ~"1/3"\n unit_name = ~r"[a-z1-3\\-]+"\n space = ~r"\\s*"\n'#
Simplified grammar used specifically for Systems S and G
mesomath.utils module#
This module contains some utility functions for MesoMath
- cunei_ljust(text: str, width: int)#
Calculate the actual visual width of the cuneiform text and justify it to left
- Parameters:
text (str) – input string
width (int) – width of the output string
- Returns:
padded string
- Return type:
str
- cunei_rjust(text: str, width: int)#
Calculate the actual visual width of the cuneiform text and justify it to right
- Parameters:
text (str) – input string
width (int) – width of the output string
- Returns:
padded string
- Return type:
str
- gen_multi_range(met: type, minv, limits, increments)#
Memory-efficient generator for metrological ranges. Yields tuple with decimal values, line number, subtotal and start of section one by one.
- Parameters:
met (type) – metrological class
minv (str) – starting value
limits (str) – final value of the sections
increments (str) – increments for each section
- Raises:
ValueError – if the number of limits does not match the number of increments.
- Returns:
decimal values of the metrological class, line number, subtotal and start of section
- Return type:
tuple (int, int, int, bool)
- to_latex_hex(text: str) str#
Encode glyphs for LaTeX
- Parameters:
text (str) – text to encode
- Returns:
encoded text
- Return type:
str
- translit_to_cunei(text: str) str#
Translate transliteration to cuneiform
- Parameters:
text (str) – transliteration to translate
- Returns:
cuneiform string
- Return type:
str
mesomath.metrology_presets module#
This module contains some metrological data
- class MetrologySeries(name: str, unit_class: str, ini: str, endlist: List[str], inclist: List[str], subst: str = '')#
Bases:
objectDataclass to hold the initial and final points and increments needed to generate the metrological list/table segments in the style of Nippur with the help of the .metrolist() and associated methods.
- __delattr__(name)#
Implement delattr(self, name).
- __eq__(other)#
Return self==value.
- __hash__()#
Return hash(self).
- __init__(name: str, unit_class: str, ini: str, endlist: List[str], inclist: List[str], subst: str = '') None#
- __repr__() str#
Displays a formatted table of the metrological series steps.
- __setattr__(name, value)#
Implement setattr(self, name, value).
- select(start_step: int, end_step: int) Tuple[str, List[str], List[str]]#
Returns a slice of the series to feed .metrolist().
- Parameters:
start_step (int) – The index of the first step (inclusive).
end_step (int) – The index of the last step (inclusive).
- Raises:
IndexError – Out of bounds for nframes
- Returns:
A tuple (initial_value, sliced_endlist, sliced_inclist)
- Return type:
Tuple[str, List[str], List[str]]
- __weakref__#
list of weak references to the object
- CAPACITY_PROUST_81 = MetrologySeries: Proust 8.1 Capacities (se) ----------------------------------------------------------------- Step | Start Value | End Value | Increment ----------------------------------------------------------------- 0 | 1 gin | 3 gin | 30 se 1 | 3 gin | 20 gin | 1 gin 2 | 20 gin | 2 sila | 10 gin 3 | 2 sila | 2 ban | 1 sila 4 | 2 ban | 1 bariga | 5 sila 5 | 1 bariga | 1 gur | 1 ban 6 | 1 gur | 2 gur | 1 bariga 7 | 2 gur | 20 gur | 1 gur 8 | 20 gur | 120 gur | 10 gur 9 | 120 gur | 1200 gur | 60 gur 10 | 1200 gur | 7200 gur | 600 gur 11 | 7200 gur | 72000 gur | 3600 gur 12 | 72000 gur | 216000 gur | 36000 gur -----------------------------------------------------------------#
Capacity metrology series
- LENGTH_PROUST_84 = MetrologySeries: Proust 8.4 Lengths () ----------------------------------------------------------------- Step | Start Value | End Value | Increment ----------------------------------------------------------------- 0 | 1 susi | 1 kus | 1 susi 1 | 1 kus | 2 kus | 5 susi 2 | 2 kus | 1 ninda | 1 kus 3 | 1 ninda | 10 ninda | 6 kus 4 | 10 ninda | 40 ninda | 10 ninda 5 | 40 ninda | 1 us | 5 ninda 6 | 1 us | 2 us | 10 ninda 7 | 2 us | 1 danna | 1 us 8 | 1 danna | 2 danna | 5 us 9 | 2 danna | 20 danna | 15 us 10 | 20 danna | 30 danna | 1 danna 11 | 30 danna | 50 danna | 5 danna 12 | 50 danna | 60 danna | 10 danna -----------------------------------------------------------------#
Length metrology series
- SURFACE_PROUST_83 = MetrologySeries: Proust 8.3 Surfaces (a-sa) ----------------------------------------------------------------- Step | Start Value | End Value | Increment ----------------------------------------------------------------- 0 | 20 gin | 2 sar | 10 gin 1 | 2 sar | 20 sar | 1 sar 2 | 20 sar | 1 gan | 10 sar 3 | 1 gan | 6 gan | 50 sar 4 | 6 gan | 18 gan | 1 gan 5 | 18 gan | 36 gan | 6 gan 6 | 36 gan | 360 gan | 18 gan 7 | 360 gan | 2160 gan | 180 gan 8 | 2160 gan | 21600 gan | 1080 gan 9 | 21600 gan | 64800 gan | 10800 gan -----------------------------------------------------------------#
Surface metrology series
- WEIGHT_PROUST_82 = MetrologySeries: Proust 8.2 Weights (ku_babbar) ----------------------------------------------------------------- Step | Start Value | End Value | Increment ----------------------------------------------------------------- 0 | 1 se | 30 se | 1 se 1 | 30 se | 40 se | 10 se 2 | 40 se | 45 se | 5 se 3 | 45 se | 50 se | 5 se 4 | 50 se | 60 se | 10 se 5 | 60 se | 90 se | 30 se 6 | 90 se | 100 se | 10 se 7 | 100 se | 105 se | 5 se 8 | 105 se | 115 se | 10 se 9 | 115 se | 120 se | 5 se 10 | 120 se | 130 se | 10 se 11 | 130 se | 135 se | 5 se 12 | 135 se | 145 se | 10 se 13 | 145 se | 150 se | 5 se 14 | 150 se | 160 se | 10 se 15 | 160 se | 165 se | 5 se 16 | 165 se | 175 se | 10 se 17 | 175 se | 1 gin | 5 se 18 | 1 gin | 2 gin | 30 se 19 | 2 gin | 20 gin | 1 gin 20 | 20 gin | 2 mana | 10 gin 21 | 2 mana | 30 mana | 1 mana 22 | 30 mana | 2 gu | 10 mana 23 | 2 gu | 20 gu | 1 gu 24 | 20 gu | 120 gu | 10 gu 25 | 120 gu | 600 gu | 60 gu 26 | 600 gu | 3600 gu | 600 gu 27 | 3600 gu | 36000 gu | 3600 gu 28 | 36000 gu | 216000 gu | 36000 gu -----------------------------------------------------------------#
Weight metrology series
mesomath.glyphs#
This module contains the cuneiform glyphs necessary for writing metrological measurements from the Old Babylonian period. You will need to have a TrueType font such as Noto Sans Cuneiform or similar installed on your system for proper display.
- DETERM = {'dug': '𒂁', 'gi': '𒄀', 'ku3': '𒆬'}#
Determinatives
- MAP_ADMIN = {'ba_til': '𒁀\u2009𒌀', 'dub': '𒁾', 'dub-sar': '𒁾\u2009𒊬', 'ib2_tag4': '𒅁\u2009𒋳', 'iti': '𒌗', 'la-ia': ' 𒇲\u2009𒉌', 'mu': '𒈬', 'mu-kux': '𒈬\u2009𒁺', 'mu_sid_bi': '𒈬\u2009𒋃\u2009𒁉', 'nig-ka': '𒃻\u2009𒅗', 'nu_til': '𒉡\u2009𒌀', 'sa10': '𒌓', 'su_ningin_gal': '𒋗\u2009𒆸\u2009𒃲', 'su_ti_a': '𒋗\u2009𒋾\u2009𒀀', 'zi-ga': ' 𒍣\u2009𒂵'}#
For colophons
- MAP_ARITHMOGRAMS = {'ash': ['𒀸', '𒐀', '𒐁', '𒐂', '𒐃', '𒐄', '𒐅', '𒐆', '𒐇'], 'dis': ['𒁹', '𒐖', '𒐈', '𒐉', '𒐊', '𒐋', '𒐌', '𒐍', '𒐎'], 'ges': ['𒐕', '𒐖', '𒐗', '𒐘', '𒐙', '𒐚', '𒐛', '𒐜', '𒐝'], 'gesu': ['𒐞', '𒐟', '𒐠', '𒐡', '𒐢'], 'sar2': ['𒊹', '𒐣', '𒐤', '𒐦', '𒐧', '𒐨', '𒐩', '𒐪', '𒐫'], 'saru': ['𒐬', '𒐭', '𒐮', '𒐰', '𒐱'], 'u': ['𒌋', '𒎙', '𒌍', '𒐏', '𒐐', '𒐑', '𒐒', '𒐓', '𒐔']}#
Dictionary for quick access by unit/system name
- MAP_UNITS = {'BARIGA': 'ሪB', 'DANNA': 'ሚ1ሆD', 'GIN2': 'ሒF', 'GUR': '𒄥', 'KUŠ3': 'ሳ3', 'MA-NA': '𒈠\u2009𒈾', 'SILA3': '𒋡', 'ŠU-SI': 'ር7ራ0'}#
Unit dictionary
- MAP_UNIT_LOGOGRAMS = {'as': '𒀸', 'ban': '𒑏', 'bariga': '𒉿', 'bur': '𒌋', 'buru': '𒐴', 'danna': '𒆜\u2009𒁍', 'dis': '𒁹', 'ese': '𒑘', 'gan': '𒃷', 'ges': '𒐕', 'gesu': '𒐞', 'gin': '𒂆', 'gu': '𒄘', 'gur': '𒄥', 'iku': '𒀸', 'kus': '𒌑', 'kush3': '𒌑', 'mana': '𒈠\u2009𒈾', 'ninda': '𒃻', 'sar': '𒊬', 'sargal': '𒊹', 'saru': '𒐬', 'se': '𒊺', 'sila': '𒋡', 'susi': '𒋗\u2009𒋛', 'u': '𒌋', 'us': '𒍑'}#
for _MesoM.schema() use
- UNIT_LOGOGRAMS = {'as': '𒀸', 'ges': '𒐕', 'gesu': '𒐞', 'kush3': '𒌑', 'ninda': '𒃻', 'sar': '𒊬', 'sargal': '𒊹', 'saru': '𒐬'}#
Mapping of internal names to Unicode logograms
- fglyphdict = {'1/2': '𒈦', '1/3': '𒑚', '1/6': '𒑡', '2/3': '𒑛', '5/6': '𒑜'}#
Klasmatograms
- l_as = ['𒀸', '𒐀', '𒐁', '𒐂', '𒐃', '𒐄', '𒐅', '𒐆', '𒐇']#
aš
- l_bur3 = ['𒌋', '𒎙', '𒌍', '𒐏', '𒐐', '𒐑', '𒐒', '𒐓', '𒐔']#
bur3
- l_buru = ['𒐴', '𒐵', '𒐶', '𒐸', '𒐹']#
buru
- l_dis = ['𒁹', '𒐖', '𒐈', '𒐉', '𒐊', '𒐋', '𒐌', '𒐍', '𒐎']#
diš
- l_ese3 = ['𒑘', '𒑙']#
eše3
- l_ges = ['𒐕', '𒐖', '𒐗', '𒐘', '𒐙', '𒐚', '𒐛', '𒐜', '𒐝']#
geš
- l_gesu = ['𒐞', '𒐟', '𒐠', '𒐡', '𒐢']#
gešu
- l_iku = ['𒀸', '𒐀', '𒐁', '𒐂', '𒐃']#
iku
- l_sar2 = ['𒊹', '𒐣', '𒐤', '𒐦', '𒐧', '𒐨', '𒐩', '𒐪', '𒐫']#
šar2
- l_sar2_gal = ['𒐲']#
šar2-gal
- l_saru = ['𒐬', '𒐭', '𒐮', '𒐰', '𒐱']#
šaru
- l_u = ['𒌋', '𒎙', '𒌍', '𒐏', '𒐐', '𒐑', '𒐒', '𒐓', '𒐔']#
u
- subsdict = {'a_ra2': '𒀀\u2009𒁺', 'a_sa': '𒀀\u2009𒊮', 'bur': '𒌋', 'da': '𒁕', 'dagal': '𒂼', 'er3': '𒀴', 'esir': '𒀀\u2009𒂍', 'ga_ar3': '𒂵\u2009𒄯', 'gada': '𒃰', 'gam': '𒃵', 'geme2': '𒊩', 'ges': '𒄑', 'ges_tin': '𒃾', 'gid': '𒁍', 'gu4': '𒄞', 'i3_gis': '𒉌\u2009𒄑', 'i3_nun': '𒉌\u2009𒉣', 'igi_nu': '𒅆\u2009𒉡', 'igi_nu_du8': '𒅆\u2009𒉡\u2009𒂃', 'kas': '𒁉', 'ki_la2': '𒆠\u2009𒆷', 'kiri6': '𒊬', 'ku3_sig17': '𒆬\u2009𒄀', 'ku_babbar': '𒆬\u2009𒌓', 'lu2': '𒇽', 'na4': '𒉌', 'sag': '𒊕', 'sag_dagal': '𒊕\u2009𒂼', 'sahar': '𒅖', 'se': '𒊺', 'sig4': '𒋞', 'siki': '𒋠', 'siki_gi': '𒋠\u2009𒄀', 'sukud': '𒊩𒆪', 'udu': '𒇻', 'urudu': '𒍏', 'us': '𒍑', 'ziz2': '𒀾', 'zu2_lum': '𒍪\u2009𒈝'}#
Substance Symbols and others:
- translit_dict = {'1(aš)': '𒀸', '1(ban2)': '𒑏', '1(barig)': '𒁹', '1(bur3)': '𒌋', '1(bur’u)': '𒐴', '1(diš)': '𒁹', '1(eše3)': '𒑘', '1(geš2)': '𒐕', '1(geš’u)': '𒐞', '1(iku)': '𒀸', '1(u)': '𒌋', '1(ubu)': '𒀹', '1(šar2)': '𒊹', '1(šargal)gal': '𒊹\u2009𒃲', '1(šar’u)': '𒐬', '1/2': '𒈦', '1/3': '𒑚', '2(aš)': '𒐀', '2(ban2)': '𒑐', '2(barig)': '𒑖', '2(bur3)': '𒎙', '2(bur’u)': '𒐵', '2(diš)': '𒐖', '2(eše3)': '𒑙', '2(geš2)': '𒐖', '2(geš’u)': '𒐟', '2(iku)': '𒐀', '2(u)': '𒎙', '2(šar2)': '𒐣', '2(šar’u)': '𒐭', '2/3': '𒑛', '3(aš)': '𒐁', '3(ban2)': '𒑑', '3(barig)': '𒑗', '3(bur3)': '𒌍', '3(bur’u)': '𒐶', '3(diš)': '𒐈', '3(geš2)': '𒐗', '3(geš’u)': '𒐠', '3(iku)': '𒐁', '3(u)': '𒌍', '3(šar2)': '𒐤', '3(šar’u)': '𒐮', '4(aš)': '𒐂', '4(ban2)': '𒑒', '4(barig)': '𒐉', '4(bur3)': '𒐏', '4(bur’u)': '𒐸', '4(diš)': '𒐉', '4(diš)gal2': '𒐉\u2009𒅅', '4(geš2)': '𒐘', '4(geš’u)': '𒐡', '4(iku)': '𒐂', '4(u)': '𒐏', '4(šar2)': '𒐦', '4(šar’u)': '𒐰', '5(aš)': '𒐃', '5(ban2)': '𒑔', '5(bur3)': '𒐐', '5(bur’u)': '𒐹', '5(diš)': '𒐊', '5(geš2)': '𒐙', '5(geš’u)': '𒐢', '5(iku)': '𒐃', '5(u)': '𒐐', '5(šar2)': '𒐧', '5(šar’u)': '𒐱', '5/6': '𒑜', '6(aš)': '𒐄', '6(bur3)': '𒐑', '6(diš)': '𒐋', '6(diš)gal2': '𒐋\u2009𒅅', '6(geš2)': '𒐚', '6(šar2)': '𒐨', '7(aš)': '𒐅', '7(bur3)': '𒐒', '7(diš)': '𒐌', '7(geš2)': '𒐛', '7(šar2)': '𒐩', '8(aš)': '𒐆', '8(bur3)': '𒐓', '8(diš)': '𒐍', '8(geš2)': '𒐜', '8(šar2)': '𒐪', '9(aš)': '𒐇', '9(bur3)': '𒐔', '9(diš)': '𒐎', '9(geš2)': '𒐝', '9(šar2)': '𒐫', 'GAN2': '𒃷', 'UŠ': '𒍑', 'a-ša3': '𒀀\u2009𒊮', 'danna': '𒆜\u2009𒁍', 'gal2': '𒅅', 'gin2': '𒂆', 'gu2': '𒄘', 'gur': '𒄥', 'igi': '𒅆', 'ku3-babbar': '𒆬\u2009𒌓', 'kuš3': '𒌑', 'ma-na': '𒈠\u2009𒈾', 'ninda': '𒃻', 'sar': '𒊬', 'sila3': '𒋡', 'še': '𒊺', 'šu-nu-tag': '𒋗\u2009𒉡\u2009𒋳', 'šu-si': '𒋗\u2009𒋛'}#
Transliteration to cuneiform dictionary
- unit_dict = {'ban': ['𒑏', '𒑐', '𒑑', '𒑒', '𒑔'], 'bariga': ['𒁹', '𒑖', '𒑗', '𒐉'], 'danna': '𒆜\u2009𒁍', 'gan': '𒃷', 'gin': '𒂆', 'gu': '𒄘', 'gur': '𒄥', 'kus': '𒌑', 'mana': '𒈠\u2009𒈾', 'ninda': '𒃻', 'sar': '𒊬', 'se': '𒊺', 'sila': '𒋡', 'susi': '𒋗\u2009𒋛', 'us': '𒍑'}#
Metrograms:
mesomath.nb_utils#
Utility functions for Jupyter Notebook environments.
- print_to_notebook(text: str)#
Print text ensuring monospaced font and cuneiform support in Notebook environments, avoiding misalignment.
- Parameters:
text (str) – Text to print
- setup_scribal_environment(font_size='1.1em')#
Injects CSS into the Jupyter/Binder environment to correctly render Noto Sans Cuneiform in both Markdown and Code outputs.
- Parameters:
font_size (str, optional) – Font size of the text in the output, defaults to “1.1em”