Explicit Units and Dimensional Analysis for Scientific Python
Project description
A runtime dimensional environment and unit-aware DSL for scientific computing in Python
PicoUnits: Usage
Picounit is a dimensional environment designed for computational science. It serves to make simulation code structurally correct and includes:
- Pluggable unit systems: Define custom base dimensions
(Unit Frames)for your domain - Configuration format:
.uivfiles with embedded, validated units &.utfor unit types - Boundary validation:
@unit_validatordecorators catch errors at function interfaces - Full numeric support: Real, complex, and array-based vectors
What is .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:
# 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
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)
voltage: 18 (V)
current_limit: 40 (A)
time_steps: 50 u(s)
atmospheric_density: 1.225 (ρ)
Quick Start
from picounits import unit_validator, VOLTAGE, CURRENT, RESISTANCE
@unit_validator(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(10 * VOLTAGE, 5 * RESISTANCE)
Documentation
Full documentation is available at docs, and beginner to advanced examples are available at examples
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 .
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
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.5.tar.gz.
File metadata
- Download URL: picounits-1.0.5.tar.gz
- Upload date:
- Size: 88.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbd1f4cbc33a6b8dc3f3b000bd3825a582661f095d7768cf1892d1f2078df0d4
|
|
| MD5 |
b90542a5b702e097277d907adfceb0ed
|
|
| BLAKE2b-256 |
11146a1e612c29f560d3570f77cba33371030045e1736d902854eab56800d60b
|
Provenance
The following attestation bundles were made for picounits-1.0.5.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.5.tar.gz -
Subject digest:
cbd1f4cbc33a6b8dc3f3b000bd3825a582661f095d7768cf1892d1f2078df0d4 - Sigstore transparency entry: 1547119604
- Sigstore integration time:
-
Permalink:
wgbowley/PicoUnits@dcaa0f816e9982c04904913813764f511652c196 -
Branch / Tag:
refs/tags/v1.0.5 - Owner: https://github.com/wgbowley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_picounits.yml@dcaa0f816e9982c04904913813764f511652c196 -
Trigger Event:
push
-
Statement type:
File details
Details for the file picounits-1.0.5-py3-none-any.whl.
File metadata
- Download URL: picounits-1.0.5-py3-none-any.whl
- Upload date:
- Size: 54.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99470f79c14b2dc2796fbfce1fc8540b311b277fcb6f19e5156a3afa328aa34e
|
|
| MD5 |
173b4a758fa196fa39b3f87aee1d8463
|
|
| BLAKE2b-256 |
f5b0dafbd8b3c52c592f8a9c999ecb8e3de9736f8837ae0f3a22f2ab92a9c8c2
|
Provenance
The following attestation bundles were made for picounits-1.0.5-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.5-py3-none-any.whl -
Subject digest:
99470f79c14b2dc2796fbfce1fc8540b311b277fcb6f19e5156a3afa328aa34e - Sigstore transparency entry: 1547119620
- Sigstore integration time:
-
Permalink:
wgbowley/PicoUnits@dcaa0f816e9982c04904913813764f511652c196 -
Branch / Tag:
refs/tags/v1.0.5 - Owner: https://github.com/wgbowley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_picounits.yml@dcaa0f816e9982c04904913813764f511652c196 -
Trigger Event:
push
-
Statement type: