Skip to main content

PicoUnits logo

A dimensional constraint system for computational engineering.

Define the dimensional environment of your application.
Keep physical meaning attached to computation.


License Python Version PyPI Downloads

[!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.

[!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: .uiv and .ut with 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, A, 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 (∅)    # Explicitly dimensionless
 
# 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 in example/.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

picounits-1.0.8.tar.gz (108.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

picounits-1.0.8-py3-none-any.whl (58.3 kB view details)

Uploaded Python 3

File details

Details for the file picounits-1.0.8.tar.gz.

File metadata

  • Download URL: picounits-1.0.8.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

Hashes for picounits-1.0.8.tar.gz
Algorithm Hash digest
SHA256 4dadb619833d12a8ff254e712a525676ca71cd2728c016c35b92a4e5fec2f5f2
MD5 932565772fbf27210ed0853690d8c9c8
BLAKE2b-256 65ac54d2145cfe259c8e578cbd2f1a429ddc6a18eb67348aedfc6cddc8c34392

See more details on using hashes here.

Provenance

The following attestation bundles were made for picounits-1.0.8.tar.gz:

Publisher: publish_picounits.yml on wgbowley/PicoUnits

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file picounits-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: picounits-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 58.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for picounits-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 1b5c75c3614845294a9deb8beb9d2e6b1dc2819ca093fc581e963cb6ee2c2c14
MD5 1f64fc968d510c865281599caf32db17
BLAKE2b-256 a2299bf65b3fb304773f801c16c8978034f0be6e77df67619ef0007b4cb3ab3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for picounits-1.0.8-py3-none-any.whl:

Publisher: publish_picounits.yml on wgbowley/PicoUnits

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.0.9

2 files

This release

1.0.8 This release

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

0.1.0

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page