Skip to main content

Mesopotamian Calculator

Project description

Docs PyPI - Version Binder

mesomath

Overview

This project aims to bring:

  • the arithmetic of natural sexagesimal numbers, mainly in their “floating” aspect (i.e., by removing all possible trailing sexagesimal zeros from the right), as performed by the Babylonian scribes and their apprentices in ancient times.

  • the arithmetic of physical quantities, length, surface, etc. described using the metrology of the Old Babylonian Period.

to Python3 programming and to the Python3 command line as an interactive calculator.

It has been inspired by the arithmetic and metrological parts of MesoCalc by Baptiste Mélès.

The package includes:

  • the mesomath module containing three main submodules:

    • babn.py: Containing the class BabN for Babylonian (sexagesimal) numbers.
    • npvs.py: Containing metrological classes for measurements of distance, area, volume, capacity, weight,...
    • hamming.py: For generating lists of regular numbers, as well as the SQLite3 database of these used by the BabN class.
  • four application submodules:

    • babcalc.py implementing the interactive Babylonian calculator babcalc.
    • metrotable.py: implementation of the metrological table printing application metrotable.
    • mtlookup.py: implementation of the metrological table search application mtlookup.
    • multable.py: implementation of the sexagesimal multiplication table printing utility bmultab.
  • Test files for pytest in the test subdirectory.

  • Sphinx source files for the documentation in the docs subdirectory, including tutorials for the four applications: babcalc, metrotable, mtlookup and bmultab.

Download

From the GitHub repository. Read below about the installation.

Documentation

Documentation for this package is in Read the Docs.

Install

For instance:

$ pip install mesomath

to install from pypi.org. Read the documentation.

Dependencies

mesomath only uses standard Python modules: math, itertools, argparse, os, re, types, typing and sqlite3.

The dependencies expressed in requirements.txt are for testing and documentation building.

Tested with Python 3.11.2 under Debian GNU/Linux 12 (bookworm) in x86_64 and aarch64 (raspberrypi 5).

babn.py

This is the main module defining the BabN class for representing sexagesimal natural numbers. You can perform mathematical operations on objects of the BabN class using the operators +, -, *, **, /, and //, and combine them using parentheses, both in a program and interactively on the Python command line. It also allows you to obtain their reciprocals in the case of regular numbers, their approximate inverses in the general case, approximate square and cube floating roots and obtain divisors and lists of "nearest" regular numbers. See the test-babn.py script.

Note:

  • Operator / return the approximate floating division of a/b for any pair of numbers.
  • Operator // is for the "Babylonian Division" of a by b, i.e. a//b returns a times the reciprocal of b, which requires b to be regular.

Use as an interactive calculator

Once mesomath is installed, simply run:

$ babcalc

Consult the tutorial!

hamming.py

Regular or Hamming numbers are numbers of the form:

H = 2^i * 3^j × 5^k

where  i, j, k ≥ 0 

This module is used to obtain lists of such numbers and ultimately build a SQLite3 database of them up to 20 sexagesimal digits. This database is used by BabN to search for regular numbers close to a given one. See the scripts: createDB.py and test-hamming.py.

npvs.py

This module defines the generic class Npvs for handling measurements in various units within a system. It is built using length measurements in the imperial system of units, from inches to leagues, as an example. This class is inherited by the _MesoM class which adapts it to Mesopotamian metrological use. The _MesoM class, in turn, is inherited by:

  • class BsyG: Babylonian counting System G (iku ese bur bur_u sar sar_u sar_gal)
  • class BsyS: Babylonian counting System S (dis u ges gesu sar sar_u sar_gal)
  • class MesoM: To represent physical quantities, inherited by:
    • class Blen: Babylonian length system (susi kus ninda us danna)
    • class Bsur: Babylonian surface system (se gin sar gan)
    • class Bvol: Babylonian volume system (se gin sar gan)
    • class Bcap: Babylonian capacity system (se gin sila ban bariga gur)
    • class Bwei: Babylonian weight system (se gin mana gu)
    • class Bbri: Babylonian brick counting system (se gin sar gan)

Please, read the tutorial to see how to use all these classes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mesomath-1.2.2.tar.gz (77.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mesomath-1.2.2-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file mesomath-1.2.2.tar.gz.

File metadata

  • Download URL: mesomath-1.2.2.tar.gz
  • Upload date:
  • Size: 77.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for mesomath-1.2.2.tar.gz
Algorithm Hash digest
SHA256 683391a60b748092092402d36da0f918732ffd7bdf2c49ef9989d2ba41e69f72
MD5 cf9ac232620120a8d4cea2b3c2a41a34
BLAKE2b-256 d73a4d9e6c375ab54e2b7e7a525a0773b843f450ad78c5e7d5e6e0fc3a234cdd

See more details on using hashes here.

File details

Details for the file mesomath-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: mesomath-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 26.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for mesomath-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64499a40428118221e99482aa588a0e6389eb2f1ba83388e93aa591627bb3555
MD5 d9df2e3acb7ab2e7579b55b41eda7623
BLAKE2b-256 e310cc3c56ec8aee0fc59f728d5aefbe107e601434f72980d7259c83227bca9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page