Hafif, hızlı ve güvenli matematiksel ifade motoru
Project description
TRAImath
Hafif, güvenli ve genişletilebilir bir Python matematik kütüphanesi.
TRAImath, NumPy veya diğer ağır bağımlılıklar olmaksızın yaygın matematik
işlemlerini sağlayan saf-Python bir kütüphanedir. eval() asla kullanılmaz;
parser modülü Shunting-Yard algoritmasıyla güvenli ifade değerlendirmesi sunar.
Özellikler
| Modül | Fonksiyonlar |
|---|---|
basic |
add, subtract, multiply, divide, modulo, floor_divide, absolute |
advanced |
power, sqrt, cbrt, factorial, log, log2, log10, exp, gcd, lcm |
geometry |
circle_area/perimeter, triangle_area, rectangle_area/perimeter, cube_volume/surface, sphere_volume/surface, cylinder_volume |
trig |
sin/cos/tan (rad & deg), asin/acos/atan/atan2, sinh/cosh/tanh, to_radians/to_degrees |
parser |
parse("2+3*5") → 17.0 — Shunting-Yard tabanlı, eval-free |
errors |
TRAIMathError, DivisionByZeroError, DomainError, InvalidExpressionError |
Kurulum
pip install .
# veya geliştirme modunda:
pip install -e .
Hızlı Başlangıç
import traimath as tm
# Temel işlemler
tm.add(3, 4) # 7
tm.divide(10, 3) # 3.333...
tm.modulo(10, 3) # 1
# Gelişmiş
tm.sqrt(144) # 12.0
tm.factorial(6) # 720
tm.log(100, 10) # 2.0
# Geometri
tm.circle_area(5) # 78.539...
tm.cube_volume(3) # 27
tm.sphere_volume(3) # 113.097...
# Trigonometri
tm.sin_deg(30) # 0.5
tm.cos_deg(60) # 0.5
tm.to_radians(180) # 3.14159...
# Parser — eval() YOK, güvenli
tm.parse("2 + 3 * 5") # 17.0
tm.parse("(2 + 3) * 5") # 25.0
tm.parse("sqrt(16) + 2^3") # 12.0
tm.parse("sin(pi / 2)") # 1.0
tm.parse("-3 * (4 + 2)") # -18.0
tm.parse("log10(1000) + e") # 5.718...
Hata Yönetimi
from traimath.errors import DivisionByZeroError, InvalidExpressionError
try:
tm.divide(5, 0)
except DivisionByZeroError as e:
print(e) # [DIVISION_BY_ZERO] Sıfıra bölme işlemi gerçekleştirilemez.
try:
tm.sqrt(-1)
except tm.DomainError as e:
print(e) # [DOMAIN_ERROR] 'sqrt' fonksiyonu için geçersiz giriş: -1
try:
tm.parse("2 ** ** 3")
except InvalidExpressionError as e:
print(e)
Testleri Çalıştırma
python -m pytest tests/ -v
Lisans
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file traimath-0.1.0.tar.gz.
File metadata
- Download URL: traimath-0.1.0.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31ffc6031088f7f7dbdf00f91c79deb0f4dc106a30233188dcbd58a4944a6f14
|
|
| MD5 |
5dfa8510d10f8e135aa5964ddcd2cbb8
|
|
| BLAKE2b-256 |
a411ae55e02f822d5fb6eaeeafbad2bd95ada94877296258eff2fec4e5be58a6
|
File details
Details for the file traimath-0.1.0-py3-none-any.whl.
File metadata
- Download URL: traimath-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b249888dbcbdd80588ca6108f8a83a715ed536fee6c602693bd30e0b706865a6
|
|
| MD5 |
c180c86be5204abf56c98022625c1d19
|
|
| BLAKE2b-256 |
3991e118ebbdee696b7ef14ba3e250a3c81f8a10e91a2dd78ea53166b86fc20e
|