A dimensional constraint system for computational engineering.
Define the dimensional environment of your application.
Keep physical meaning attached to computation.
[!NOTE] PicoUnits is the dimensional environment underlying
PyFea,PicoMaterials, and other cross-domain engineering projects.
Overview
PicoUnits is a dimensional constraint system for computational engineering.
Unlike general-purpose unit libraries, PicoUnits separates:
- The underlying algebraic structure of a physical quantity.
- Prefixes represent scale along an existing dimensional axis.
- The symbols used to represent dimensions and derived units belong to the application's
unit frame.
Features
[!important]
- Pluggable unit systems via
Unit Frames(domain-specific base dimensions)- Algebra-first unit system: no implicit or explicit unit conversion
- Prefixes are representational and do not participate in unit algebra
- Configuration format:
.uivand.utwith embedded validation- Boundary validation via
@expects- Full numeric support: real, complex, and vector quantities
Not a Unit Conversion Library
PicoUnits was never intended or designed as a universal unit conversion system.
It does not attempt to answer:
3 metres → ? feet
Instead, it answers questions such as:
- Does this quantity have the required dimensions?
- Are these two physical quantities algebraically compatible?
- Can this solver safely consume this value?
What is a unit frame?
A unit frame defines the dimensional environment used by an application.
For example:
[symbols]
time: s
length: m
mass: kg
current: A
TEMPERATURE: K
amount: mol
luminosity: cd
dimensionless: ∅
The underlying dimensional basis is independent of the notation used to represent it. The notation is simply a semantic layer applied over the same mathematical rules.
What are .uiv & .ut?
Both are dimensionally aware formats. .ut (unit types) encodes custom base units for your system and .uiv (unit informed values) encodes value:unit pairs:
.ut
# Coilgun Units - Derived from Base Dimensions (kg, m, s, etc.)
[version]
format: 0.1.0
[units]
ρ: kg/m^3
V: kg*m^2*s^-3*A^-1
.uiv
All value : unit pairs exist in the form value prefix(unit), for example:
[version]
format: 0.1.0
unit_frame: units.ut
[notes]
# Analytical model for a multi-stage coil-gun
# Models electrical, magnetic and motional dynamics
[model]
number_stages: 10
# Millimeter -> prefix `m` and unit `m` hence prefix(unit), m(m)
stage_gap: 10 m(m)
# Value without prefix (volts - empty prefix)
voltage: 18 (V) # Equivalent to ""(V)
current_limit: 40 (A)
time_steps: 50 u(s)
atmospheric_density: 1.225 (ρ)
Quick Start
from picounits import expects, VOLTAGE, CURRENT, RESISTANCE
@expects(VOLTAGE)
def ohm_law(i, r):
return i * r
# Correct usage
v = ohm_law(10 * CURRENT, 5 * RESISTANCE)
print(v) # Output: 50.0 (kg·m²·s⁻³·A⁻¹) (Derived units need to be pulled in via .ut)
# This would raise a DimensionError:
# 'ohm_law' returned kg²·m⁴·s⁻⁶·A⁻³, expected kg·m²·s⁻³·A⁻¹
Installation
To install:
# Recommended for most users
pip install PicoUnits
or use setuptools locally:
git clone https://github.com/wgbowley/PicoUnits.git
cd PicoUnits
pip install -e .
Documentation
[!NOTE] Documentation is available in
docs/, with a standard introduction example available inexamples/.
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 picounits-1.0.6.tar.gz.
File metadata
- Download URL: picounits-1.0.6.tar.gz
- Upload date:
- Size: 108.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ac6555b2eec4ff086181ee4c78bd47d72757d141a9fed24fcdd7a25ae4c860f
|
|
| MD5 |
66d8db02e1bfada9cd13f29d931a9c36
|
|
| BLAKE2b-256 |
7c40c54b27b74e8f2c131d2a2580a8d3d05bc695a2ecdd3cfaf6049e2636d778
|
Provenance
The following attestation bundles were made for picounits-1.0.6.tar.gz:
Publisher:
publish_picounits.yml on wgbowley/PicoUnits
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
picounits-1.0.6.tar.gz -
Subject digest:
6ac6555b2eec4ff086181ee4c78bd47d72757d141a9fed24fcdd7a25ae4c860f - Sigstore transparency entry: 2229010010
- Sigstore integration time:
-
Permalink:
wgbowley/PicoUnits@607fef485126d6666aa0f51a860e24e4ed1d0f1c -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/wgbowley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_picounits.yml@607fef485126d6666aa0f51a860e24e4ed1d0f1c -
Trigger Event:
push
-
Statement type:
File details
Details for the file picounits-1.0.6-py3-none-any.whl.
File metadata
- Download URL: picounits-1.0.6-py3-none-any.whl
- Upload date:
- Size: 58.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac05acd3137ab3ee2153ac952ab73242a82e0197896d667d521fcc3d5725aaf6
|
|
| MD5 |
a95b261e64365c53b9978e1e1aac10d7
|
|
| BLAKE2b-256 |
08ac6f53654ce73ea6fd20746edd45da662db5b035504fad51112dcb2a410153
|
Provenance
The following attestation bundles were made for picounits-1.0.6-py3-none-any.whl:
Publisher:
publish_picounits.yml on wgbowley/PicoUnits
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
picounits-1.0.6-py3-none-any.whl -
Subject digest:
ac05acd3137ab3ee2153ac952ab73242a82e0197896d667d521fcc3d5725aaf6 - Sigstore transparency entry: 2229010269
- Sigstore integration time:
-
Permalink:
wgbowley/PicoUnits@607fef485126d6666aa0f51a860e24e4ed1d0f1c -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/wgbowley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_picounits.yml@607fef485126d6666aa0f51a860e24e4ed1d0f1c -
Trigger Event:
push
-
Statement type: