Metadata-Version: 2.4
Name: PicoUnits
Version: 1.0.5
Summary: Explicit Units and Dimensional Analysis for Scientific Python
Project-URL: Homepage, https://github.com/wgbowley/picounits
Project-URL: Bug Tracker, https://github.com/wgbowley/picounits/issues
Author-email: William Bowley <wgrantbowley@gmail.com>
Maintainer-email: William Bowley <wgrantbowley@gmail.com>
License: MIT License
        
        Copyright (c) 2025 William Bowley
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: error-checking,minimal,physics,si,units
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.8
Requires-Dist: numpy
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://github.com/wgbowley/PicoUnits">
    <img src="https://raw.githubusercontent.com/wgbowley/PicoUnits/main/media/picounit_logo.png" 
         alt="PicoUnits">
  </a>
</p>

<p align="center">A runtime dimensional environment and unit-aware DSL for scientific computing in Python</p>

## PicoUnits: Usage
<!-- NOTE: Python version needs to checked before release, I am not sure the specific version  -->
![Python Version](https://img.shields.io/badge/python-3.10+-900001)
![WIP](https://img.shields.io/badge/status-WIP-D7DFE1)
![License](https://img.shields.io/badge/license-MIT-900001)

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**:  `.uiv` files with embedded, validated units & `.ut` for unit types
- **Boundary validation**:  `@unit_validator` decorators 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

```python
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 <a style="color: #861211" href="/docs/">docs</a>, and beginner to advanced examples are available at 
<a style="color: #861211" href="/examples/">examples</a>

## Installation
To install:
```bash
# Recommended for most users
pip install PicoUnits
```
or use setuptools locally:

```bash
git clone https://github.com/wgbowley/PicoUnits.git
cd PicoUnits
pip install -e .
```
 
