Skip to main content

A pure-Python math utility library.

Project description

taha-math-shiraz

A pure-Python library that reimplements Python's built-in math module (and the statistics module) completely from scratch, without relying on math or cmath internally, plus a large collection of extra utilities: number theory, linear algebra, geometry, calculus, interpolation, probability distributions, base conversions, and more.

Installation

pip install .

or simply copy the taha_math_shiraz/ folder next to your project.

Usage

import taha_math_shiraz as tms

print(tms.PI)
print(tms.sqrt(2))
print(tms.sin(tms.PI / 2))
print(tms.factorial(10))
print(tms.is_prime(97))
print(tms.mean([1, 2, 3, 4, 5]))

m = tms.Matrix([[1, 2], [3, 4]])
print(m.determinant())

You can also import only what you need from a specific submodule:

from taha_math_shiraz.trigonometry import sin, cos
from taha_math_shiraz.linalg import Vector, Matrix
from taha_math_shiraz.numbertheory import is_prime, fibonacci

Package layout

taha_math_shiraz/
    __init__.py        re-exports the full public API
    constants.py        PI, E, TAU, INF, NAN, ...
    basics.py            fabs, floor, ceil, fmod, isnan, isinf, ...
    numtheory_core.py    factorial, gcd, lcm, isqrt
    power.py             sqrt, cbrt, pow_, exp, log, log2, log10, ...
    trigonometry.py      sin, cos, tan, asin, acos, atan, sinh, cosh, ...
    aggregates.py        fsum, prod, isclose, comb, perm
    special.py           gamma, lgamma, erf, erfc, frexp, ldexp, ...
    numbertheory.py      primes, divisors, totient, fibonacci, polygonal numbers, ...
    statistics_mod.py    mean, median, mode, variance, stdev, correlation, ...
    probability.py       binomial/normal/poisson/exponential distributions
    linalg.py            Vector, Matrix, Complex and related helpers
    combinatorics.py     permutations, combinations, partitions, bell numbers
    geometry.py          areas, volumes, distances, line intersection, ...
    calculus.py          derivative, integral, root-finding methods
    conversions.py       unit conversions (temperature, distance, mass)
    interpolation.py     Lagrange/Newton interpolation, continued fractions
    randomutil.py        a simple linear congruential generator
    baseconv.py          base conversion, Roman numerals
    series.py            arithmetic/geometric series sums
    activations.py       sigmoid, relu, clamp, lerp, smoothstep
    metrics.py           distRan rg --files
    ساختار پروژه را پیدا کردم: یک پکیج taha_math_shiraz با چندین ماژول عددی/ریاضی و یک مجموعه تست نسبتاً کامل. الان README و فایل‌های اصلی ورودی پکیج را می‌خوانم تا بفهمم API عمومی دقیقاً چیست و بعد سراغ ماژول‌های داخلی می‌روم.ance metrics, cosine similarity

Tests

Tests live in the tests/ folder and are split by topic, mirroring the package layout. Run all of them with:

python -m unittest discover -s tests -v
math-module-tahazare
├─ README.md
├─ taha_math_shiraz
│  ├─ activations.py
│  ├─ aggregates.py
│  ├─ algorithms.py
│  ├─ baseconv.py
│  ├─ basics.py
│  ├─ calculus.py
│  ├─ combinatorics.py
│  ├─ constants.py
│  ├─ conversions.py
│  ├─ crypto.py
│  ├─ datatypes.py
│  ├─ geometry.py
│  ├─ graph.py
│  ├─ interpolation.py
│  ├─ linalg.py
│  ├─ metrics.py
│  ├─ numbertheory.py
│  ├─ numtheory_core.py
│  ├─ polynomial.py
│  ├─ power.py
│  ├─ probability.py
│  ├─ randomutil.py
│  ├─ series.py
│  ├─ special.py
│  ├─ statistics_mod.py
│  ├─ trigonometry.py
│  ├─ __init__.py
│  └─ __pycache__
│     ├─ activations.cpython-313.pyc
│     ├─ activations.cpython-314.pyc
│     ├─ aggregates.cpython-313.pyc
│     ├─ aggregates.cpython-314.pyc
│     ├─ algorithms.cpython-313.pyc
│     ├─ algorithms.cpython-314.pyc
│     ├─ baseconv.cpython-313.pyc
│     ├─ baseconv.cpython-314.pyc
│     ├─ basics.cpython-313.pyc
│     ├─ basics.cpython-314.pyc
│     ├─ calculus.cpython-313.pyc
│     ├─ calculus.cpython-314.pyc
│     ├─ combinatorics.cpython-313.pyc
│     ├─ combinatorics.cpython-314.pyc
│     ├─ constants.cpython-313.pyc
│     ├─ constants.cpython-314.pyc
│     ├─ conversions.cpython-313.pyc
│     ├─ conversions.cpython-314.pyc
│     ├─ crypto.cpython-313.pyc
│     ├─ crypto.cpython-314.pyc
│     ├─ datatypes.cpython-313.pyc
│     ├─ datatypes.cpython-314.pyc
│     ├─ geometry.cpython-313.pyc
│     ├─ geometry.cpython-314.pyc
│     ├─ graph.cpython-313.pyc
│     ├─ graph.cpython-314.pyc
│     ├─ interpolation.cpython-313.pyc
│     ├─ interpolation.cpython-314.pyc
│     ├─ linalg.cpython-313.pyc
│     ├─ linalg.cpython-314.pyc
│     ├─ metrics.cpython-313.pyc
│     ├─ metrics.cpython-314.pyc
│     ├─ numbertheory.cpython-313.pyc
│     ├─ numbertheory.cpython-314.pyc
│     ├─ numtheory_core.cpython-313.pyc
│     ├─ numtheory_core.cpython-314.pyc
│     ├─ polynomial.cpython-313.pyc
│     ├─ polynomial.cpython-314.pyc
│     ├─ power.cpython-313.pyc
│     ├─ power.cpython-314.pyc
│     ├─ probability.cpython-313.pyc
│     ├─ probability.cpython-314.pyc
│     ├─ randomutil.cpython-313.pyc
│     ├─ randomutil.cpython-314.pyc
│     ├─ series.cpython-313.pyc
│     ├─ series.cpython-314.pyc
│     ├─ special.cpython-313.pyc
│     ├─ special.cpython-314.pyc
│     ├─ statistics_mod.cpython-313.pyc
│     ├─ statistics_mod.cpython-314.pyc
│     ├─ trigonometry.cpython-313.pyc
│     ├─ trigonometry.cpython-314.pyc
│     ├─ __init__.cpython-313.pyc
│     └─ __init__.cpython-314.pyc
├─ temp.py
└─ tests
   ├─ test_activations.py
   ├─ test_basics.py
   ├─ test_calculus.py
   ├─ test_constants.py
   ├─ test_geometry.py
   ├─ test_interpolation_conversion.py
   ├─ test_legacy_self_checks.py
   ├─ test_linalg.py
   ├─ test_new_modules.py
   ├─ test_numbertheory.py
   ├─ test_power.py
   ├─ test_special.py
   ├─ test_statistics.py
   ├─ test_trigonometry.py
   └─ __init__.py

math-module-tahazare
├─ .agents
├─ dist
│  ├─ taha_math_shiraz-1.1.0-py3-none-any.whl
│  └─ taha_math_shiraz-1.1.0.tar.gz
├─ docs
│  ├─ document.html
│  ├─ document_english.html
│  ├─ generated_outputs.json
│  ├─ language.html
│  ├─ math-module-logo.png
│  ├─ style_English.css
│  └─ style_persian.css
├─ pyproject.toml
├─ README.md
├─ src
│  ├─ taha_math_shiraz
│  │  ├─ activations.py
│  │  ├─ aggregates.py
│  │  ├─ algorithms.py
│  │  ├─ baseconv.py
│  │  ├─ basics.py
│  │  ├─ calculus.py
│  │  ├─ combinatorics.py
│  │  ├─ constants.py
│  │  ├─ conversions.py
│  │  ├─ crypto.py
│  │  ├─ datatypes.py
│  │  ├─ geometry.py
│  │  ├─ graph.py
│  │  ├─ interpolation.py
│  │  ├─ linalg.py
│  │  ├─ metrics.py
│  │  ├─ numbertheory.py
│  │  ├─ numtheory_core.py
│  │  ├─ polynomial.py
│  │  ├─ power.py
│  │  ├─ probability.py
│  │  ├─ randomutil.py
│  │  ├─ series.py
│  │  ├─ special.py
│  │  ├─ statistics_mod.py
│  │  ├─ trigonometry.py
│  │  ├─ __init__.py
│  │  └─ __pycache__
│  │     ├─ activations.cpython-314.pyc
│  │     ├─ aggregates.cpython-314.pyc
│  │     ├─ algorithms.cpython-314.pyc
│  │     ├─ baseconv.cpython-314.pyc
│  │     ├─ basics.cpython-314.pyc
│  │     ├─ calculus.cpython-314.pyc
│  │     ├─ combinatorics.cpython-314.pyc
│  │     ├─ constants.cpython-314.pyc
│  │     ├─ conversions.cpython-314.pyc
│  │     ├─ crypto.cpython-314.pyc
│  │     ├─ datatypes.cpython-314.pyc
│  │     ├─ geometry.cpython-314.pyc
│  │     ├─ graph.cpython-314.pyc
│  │     ├─ interpolation.cpython-314.pyc
│  │     ├─ linalg.cpython-314.pyc
│  │     ├─ metrics.cpython-314.pyc
│  │     ├─ numbertheory.cpython-314.pyc
│  │     ├─ numtheory_core.cpython-314.pyc
│  │     ├─ polynomial.cpython-314.pyc
│  │     ├─ power.cpython-314.pyc
│  │     ├─ probability.cpython-314.pyc
│  │     ├─ randomutil.cpython-314.pyc
│  │     ├─ series.cpython-314.pyc
│  │     ├─ special.cpython-314.pyc
│  │     ├─ statistics_mod.cpython-314.pyc
│  │     ├─ trigonometry.cpython-314.pyc
│  │     └─ __init__.cpython-314.pyc
│  ├─ __init__.py
│  └─ __pycache__
│     └─ __init__.cpython-314.pyc
├─ taha_math_shiraz
│  ├─ __init__.py
│  └─ __pycache__
│     ├─ activations.cpython-313.pyc
│     ├─ activations.cpython-314.pyc
│     ├─ aggregates.cpython-313.pyc
│     ├─ aggregates.cpython-314.pyc
│     ├─ algorithms.cpython-313.pyc
│     ├─ algorithms.cpython-314.pyc
│     ├─ baseconv.cpython-313.pyc
│     ├─ baseconv.cpython-314.pyc
│     ├─ basics.cpython-313.pyc
│     ├─ basics.cpython-314.pyc
│     ├─ calculus.cpython-313.pyc
│     ├─ calculus.cpython-314.pyc
│     ├─ combinatorics.cpython-313.pyc
│     ├─ combinatorics.cpython-314.pyc
│     ├─ constants.cpython-313.pyc
│     ├─ constants.cpython-314.pyc
│     ├─ conversions.cpython-313.pyc
│     ├─ conversions.cpython-314.pyc
│     ├─ crypto.cpython-313.pyc
│     ├─ crypto.cpython-314.pyc
│     ├─ datatypes.cpython-313.pyc
│     ├─ datatypes.cpython-314.pyc
│     ├─ geometry.cpython-313.pyc
│     ├─ geometry.cpython-314.pyc
│     ├─ graph.cpython-313.pyc
│     ├─ graph.cpython-314.pyc
│     ├─ interpolation.cpython-313.pyc
│     ├─ interpolation.cpython-314.pyc
│     ├─ linalg.cpython-313.pyc
│     ├─ linalg.cpython-314.pyc
│     ├─ metrics.cpython-313.pyc
│     ├─ metrics.cpython-314.pyc
│     ├─ numbertheory.cpython-313.pyc
│     ├─ numbertheory.cpython-314.pyc
│     ├─ numtheory_core.cpython-313.pyc
│     ├─ numtheory_core.cpython-314.pyc
│     ├─ polynomial.cpython-313.pyc
│     ├─ polynomial.cpython-314.pyc
│     ├─ power.cpython-313.pyc
│     ├─ power.cpython-314.pyc
│     ├─ probability.cpython-313.pyc
│     ├─ probability.cpython-314.pyc
│     ├─ randomutil.cpython-313.pyc
│     ├─ randomutil.cpython-314.pyc
│     ├─ series.cpython-313.pyc
│     ├─ series.cpython-314.pyc
│     ├─ special.cpython-313.pyc
│     ├─ special.cpython-314.pyc
│     ├─ statistics_mod.cpython-313.pyc
│     ├─ statistics_mod.cpython-314.pyc
│     ├─ trigonometry.cpython-313.pyc
│     ├─ trigonometry.cpython-314.pyc
│     ├─ __init__.cpython-313.pyc
│     └─ __init__.cpython-314.pyc
├─ taha_math_shiraz.egg-info
│  ├─ dependency_links.txt
│  ├─ PKG-INFO
│  ├─ SOURCES.txt
│  └─ top_level.txt
├─ temp.py
└─ tests
   ├─ test_activations.py
   ├─ test_basics.py
   ├─ test_calculus.py
   ├─ test_constants.py
   ├─ test_geometry.py
   ├─ test_interpolation_conversion.py
   ├─ test_legacy_self_checks.py
   ├─ test_linalg.py
   ├─ test_new_modules.py
   ├─ test_numbertheory.py
   ├─ test_power.py
   ├─ test_special.py
   ├─ test_statistics.py
   ├─ test_trigonometry.py
   ├─ __init__.py
   └─ __pycache__
      ├─ test_activations.cpython-314.pyc
      ├─ test_basics.cpython-314.pyc
      ├─ test_calculus.cpython-314.pyc
      ├─ test_constants.cpython-314.pyc
      ├─ test_geometry.cpython-314.pyc
      ├─ test_interpolation_conversion.cpython-314.pyc
      ├─ test_legacy_self_checks.cpython-314.pyc
      ├─ test_linalg.cpython-314.pyc
      ├─ test_new_modules.cpython-314.pyc
      ├─ test_numbertheory.cpython-314.pyc
      ├─ test_power.cpython-314.pyc
      ├─ test_special.cpython-314.pyc
      ├─ test_statistics.cpython-314.pyc
      └─ test_trigonometry.cpython-314.pyc

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

taha_math_shiraz-1.1.0.tar.gz (78.0 kB view details)

Uploaded Source

Built Distribution

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

taha_math_shiraz-1.1.0-py3-none-any.whl (36.1 kB view details)

Uploaded Python 3

File details

Details for the file taha_math_shiraz-1.1.0.tar.gz.

File metadata

  • Download URL: taha_math_shiraz-1.1.0.tar.gz
  • Upload date:
  • Size: 78.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for taha_math_shiraz-1.1.0.tar.gz
Algorithm Hash digest
SHA256 03a34d98a781aa8e00620947d348d2e46b6b771d905d3fd0c841675cf9cfe0fe
MD5 fcdd7789616d8eb919f3d106967c1c47
BLAKE2b-256 d67c0096e3fd97cfa6eb6c37292ad538102af02783280e3db51217d7c6c71bf6

See more details on using hashes here.

File details

Details for the file taha_math_shiraz-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for taha_math_shiraz-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de15ada484e88818a694e0f58368539527580b2da08761bb3046192eaf79d730
MD5 08820faa9d34ddcdb60c20a4ad0f7c31
BLAKE2b-256 e3815a37ec65d0206532361f2cf58f9c381db059ac63955be7a4b049b442ad73

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