Sexagesimal Calculator
A robust, modern Python library for high-precision sexagesimal (base-60) arithmetic, born from a project for the History of Mathematics in India (HoMI) initiative at Indian Institute of Technology, Gandhinagar.
This library provides a Sexagesimal class that represents numbers as immutable objects, allowing for intuitive and accurate calculations. It is ideal for applications in historical mathematics, astronomy, and any domain requiring base-60 computation.
Full Documentation | PyPI Project | Source Code
Features
- Immutable Objects:
Sexagesimalnumbers are immutable, ensuring predictable and bug-free calculations. - Intuitive API: Use standard Python operators (
+,-,*,/,**,round()) for all arithmetic. - High Precision: Backed by Python's
Decimalandsympy.Rationalfor conversions, guaranteeing precision. - Flexible Initialization: Create
Sexagesimalnumbers from integers, floats, decimals, or strings. - Educational Tools: Generate beautiful, step-by-step explanations of calculations, perfect for teaching or validation.
- Fully Typed and Tested: High test coverage with a comprehensive
pytestandhypothesissuite.
Installation
This package is hosted on PyPI.
pip install sexagesimal-calculator
# OR
uv add sexagesimal-calculator
Basic Usage
The core of the library is the Sexagesimal class.
from sexagesimal_calculator import Sexagesimal
# Initialization is flexible
a = Sexagesimal("10;15,30") # From a sexagesimal string
b = Sexagesimal(1.75) # From a float
c = Sexagesimal("-5") # From an integer string
print(f"A = {a}") # A = 10;15,30
print(f"B = {b}") # B = 01;45
print(f"C = {c}") # C = -05;00
# Arithmetic uses standard Python operators
sum_val = a + b
print(f"A + B = {sum_val}") # A + B = 12;00,30
# Convert to a high-precision Decimal
dec_val = sum_val.to_decimal()
print(f"Sum as Decimal: {dec_val}") # Sum as Decimal: 12.008333...
# Rounding
rounded = Sexagesimal("21;19,53,47").round(precision=2)
print(f"Rounded value: {rounded}") # Rounded value: 21;19,54
Explanations Feature
A standout feature is the ability to generate detailed, step-by-step explanations for calculations.
from sexagesimal_calculator import explain_multiplication
a = Sexagesimal("01;15")
b = Sexagesimal("02;30")
# Generate the explanation object
explanation = explain_multiplication(a, b)
# Print the beautiful, colored explanation to your terminal
explanation.print()
This produces a detailed, formatted breakdown of the entire long multiplication process, perfect for educational purposes. Similar functions (explain_addition, explain_subtraction, explain_division) are also available.
Development
To set up for development, clone the repository and use uv to sync dependencies.
git clone https://github.com/HrushikeshPawar/Sexagesimal-Calculator.git
cd Sexagesimal-Calculator
uv sync --all-packages
To run the test suite with coverage:
uv run pytest --cov=src/sexagesimal_calculator
Metadata
Release files for sexagesimal-calculator 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sexagesimal_calculator-2.0.1.tar.gz | 21.5 kB | Without provenance | Details for sexagesimal_calculator-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sexagesimal_calculator-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for sexagesimal_calculator-2.0.1-py3-none-any.whl |
Total release size: 47.3 kB
Release files / sexagesimal_calculator-2.0.1.tar.gz
| Download URL | sexagesimal_calculator-2.0.1.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
143e70b21c73982b315fc71609372d6d187a506c188baffce9f9ff170da72d75
|
|
BLAKE2b-256 checksum How to use checksums |
3b20a0b0ef5a99fde5125849c751e9de90a2bb13eeed85fbcbddd3421843d217
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.22
|
Release files / sexagesimal_calculator-2.0.1-py3-none-any.whl
| Download URL | sexagesimal_calculator-2.0.1-py3-none-any.whl |
|---|---|
| Size | 25.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc32720824eb53dbff9f026d61c6b1efb3f3d7637cd0b01b4bf83a48952da64c
|
|
BLAKE2b-256 checksum How to use checksums |
924f9a020470d2c4650a3261e4397485bed16641997adcf5c3eebf871700f431
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.22
|
Security for sexagesimal-calculator 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.