UnitFlow
Elegant engineering math for Python.
Unit algebra. Dimensional reasoning. Symbolic constraints. Array workflows. Built for engineers who refuse to compromise on correctness or beauty.
Installation
pip install unitflow
For NumPy support:
pip install unitflow[numpy]
The core library has zero dependencies. NumPy is optional.
Quick Start
from unitflow import m, cm, kg, s, N, kW, MW, rpm, rad, si
# Intuitive arithmetic
force = 2 * kg * 9.81 * (m / s**2)
print(force.to(N)) # 19.62 N
# Exact conversions across orders of magnitude
power = 5000 * si.W
print(power.to(kW)) # 5 kW
print(power.to(MW)) # 0.005 MW
# Angular speed with exact pi-bearing scale factors
angular = (3000 * rpm).to(rad / s)
print(angular) # 314.159... rad/s
# Semantic equality: same physics, same object
assert 1 * m == 100 * cm
assert hash(1 * m) == hash(100 * cm)
Features
- Clean Unit Algebra -- Immutable, composable units with automatic dimension tracking.
- Exact Scale Representation -- Rational arithmetic with explicit pi support. No floating-point drift.
- SI Prefix System -- Every standard prefix from pico to tera, generated programmatically.
- Torque vs Energy Disambiguation -- Same dimension, different meaning. UnitFlow knows the difference.
- Symbolic Constraints -- Define equations and inequalities as first-class Python objects for MBSE.
- NumPy Integration -- Array-backed quantities via
__array_ufunc__and__array_function__. - JSON-Safe Serialization -- Quantities and constraint trees serialize to plain dicts.
- Explicit Errors -- Dimension mismatches and incompatible conversions fail loudly. No silent corruption.
Symbolic Constraints
from unitflow import symbol, N, kg, m, s, W, rpm, rad
F = symbol("F", unit=N)
mass = symbol("m", unit=kg)
a = symbol("a", unit=m / s**2)
newtons_law = F == mass * a # Returns an Equation, not a bool
x = symbol("x", unit=m)
bounds = (0 * m <= x) & (x <= 10 * m) # Conjunction of constraints
User-Defined Units
from unitflow import define_unit, UnitNamespace, Quantity, m, s, generate_prefixes
from fractions import Fraction
ft = define_unit(name="foot", symbol="ft", expr=Quantity(Fraction(3048, 10000), m))
print((6 * ft).to(m)) # 1.8288 m
aero = UnitNamespace("aero")
knot = aero.define_unit(name="knot", symbol="kn", expr=Quantity(Fraction(1852, 3600), m / s))
generate_prefixes(aero, knot, include={"milli", "kilo"})
Part of ThunderGraph
UnitFlow is the foundational math layer for ThunderGraph, an AI-powered model-based systems engineering platform.
Links
License
Apache 2.0
Metadata
Release files for unitflow 0.2.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 |
|---|---|---|---|---|
| unitflow-0.2.1.tar.gz | 1.9 MB | Without provenance | Details for unitflow-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| unitflow-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for unitflow-0.2.1-py3-none-any.whl |
Total release size: 2.0 MB
Release files / unitflow-0.2.1.tar.gz
| Download URL | unitflow-0.2.1.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd1570afd4db1187c0a0bf8f7daa836e9d6e204c7d9ba6bd4d9ccb8d185f7edd
|
|
BLAKE2b-256 checksum How to use checksums |
1eee286eac876ecd306096a94ba296fd1e666ee849d034dad8cf95e5c489887c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.3
|
Release files / unitflow-0.2.1-py3-none-any.whl
| Download URL | unitflow-0.2.1-py3-none-any.whl |
|---|---|
| Size | 36.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb8671f3198c2efa561f66ae3abb34b61aad0c7686118db5c568a87a78d748f9
|
|
BLAKE2b-256 checksum How to use checksums |
263c61b5146065ad42ad9815e91f0c255b78a64110c13d889306e9222fca8420
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.3
|
Security for unitflow 0.2.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.