CannabisMath (Python)
CannabisMath is a cross-platform cannabis calculation library designed for accuracy, consistency, and real-world retail use.
This Python package provides deterministic calculations for:
- Potency (THC / CBD from COA values)
- Dosing (mg calculations)
- Weight conversions (grams, ounces, pounds)
- Pricing (price per gram / mg)
- Taxes
- Rounding (including POS-safe nickel rounding)
- Packaging and retail breakdowns
- Composite value calculations
Installation
pip install cannabismath
Quick Start
from cannabismath import PotencyCalculator
total_thc = PotencyCalculator.calculate_total_thc(1.2, 24.8) print(total_thc) # 22.9496
Why CannabisMath?
Cannabis calculations are often inconsistent across apps, dashboards, and POS systems.
Differences in:
- rounding rules
- weight assumptions
- potency formulas
- tax handling
can lead to mismatched results and real operational issues.
CannabisMath provides a single, deterministic calculation layer to ensure consistent results across systems and languages.
Cross-Platform Design
CannabisMath is designed to produce identical results across:
- C# (NuGet)
- TypeScript (NPM)
- Python (PyPI)
All implementations share the same test fixtures to guarantee parity.
Example: Dosing
from cannabismath import DoseCalculator
total_mg = DoseCalculator.total_mg_from_percent(3.5, 20) print(total_mg) # 700
Example: Rounding
from cannabismath import RoundingCalculator
rounded = RoundingCalculator.round_cash_to_nearest_nickel(10.03) print(rounded) # 10.05
Test Integrity
CannabisMath uses shared JSON test fixtures across all languages to ensure:
- consistent outputs
- no drift between implementations
- predictable results for real-world usage
Use Cases
- Dispensary POS systems
- Cannabis analytics dashboards
- Inventory and pricing tools
- Data pipelines and automation scripts
- Consumer-facing calculators
Disclaimer
CannabisMath is a calculation library only.
It is not legal, tax, medical, or compliance advice.
Always verify calculations against local regulations.
License
MIT
Metadata
Release files for cannabismath 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cannabismath-0.1.2.tar.gz | 2.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cannabismath-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.1 kB
Release files / cannabismath-0.1.2.tar.gz
| Download URL | cannabismath-0.1.2.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d9effc679bc1e7a9e1f126e50df4cc799712cb29cf576f5bfe358db637005b06
|
|
BLAKE2b-256 checksum How to use checksums |
a86437b0e85d281b15113ae1ab93637eb3ab05aca26964db236b40e0a091f72c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / cannabismath-0.1.2-py3-none-any.whl
| Download URL | cannabismath-0.1.2-py3-none-any.whl |
|---|---|
| Size | 2.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a3fdb2ceb21ac5558cbabe1a49e0d7ec75e50575499d97e6907ed6be5181db9
|
|
BLAKE2b-256 checksum How to use checksums |
ef7c86067441be6aea1c6b8d7b31bf60dc3c483cb4eba14290bf65045f176d1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|