Metadata-Version: 2.5
Name: PicoUnits
Version: 1.0.9
Summary: A Dynamic Runtime Type System for Dimensional Numerical Quantities.
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.10
Requires-Dist: numpy
Description-Content-Type: text/markdown

<!--
#006d77ff, 
#d92c2aff 
Hello,
PicoUnits only exists because I got annoyed by the 
uncertainty of other unit systems and I wanted a 
language that can encode parameters into it (UnitValues).

I think the final result here is quite reasonable for 
that initial problem. I hope you enjoy using PicoUnits.

William Bowley, 
20th August, 2026

P.S: Thanks for downloading our PicoUnits repository `▽`ʃ♡
-->

<!-- Make sure to update the logo with the github link before release if changed -->

<p align="center">
<img src="https://raw.githubusercontent.com/Bowley-Systems/PicoUnits/refs/heads/main/media/logo.png" alt="PicoUnits logo" style="width:100%; max-width:100%; display:block;"></p>
</p>
<h4 align="center">A Dynamic Runtime Type System for Dimensional Numerical Quantities.</h4>
<p align="center">
  Define the type. Define the variable. Execute. <br>
  Automate physical meaning throughout your pipeline.
</p>

## Overview

<!--
Make sure to update the coverage value 
(if unit tests are done for the update). 
It is not automatic. 
--> 

![License](https://img.shields.io/badge/License-MIT-E14F4C?style=flat-square)
![Python Version](https://img.shields.io/badge/Python-3.10%2B-006D77?style=flat-square)
![Coverage](https://img.shields.io/badge/coverage-61%25-E14F4C?style=flat-square)
[![PyPI Downloads](https://img.shields.io/pepy/dt/picounits?label=downloads\&style=flat-square\&color=006D77)](https://pepy.tech/projects/picounits)

PicoUnits is a dynamic runtime dimensional typing system for numerical quantities. It provides a consistent type system for expressing dimensional quantities throughout your pipeline.

> [!important]
>
> ### Features:
> - Configurable `unit frames` with custom symbols and dimension ordering
> - Parses `UnitValues` language formats: unit types (`.ut`) and unit-informed values (`.uiv`)
> - Numerical support for real, complex, and vector quantities

## Why convert at all?

PicoUnits removes uncertainty by reducing the set of units to one canonical set defined by the user.

It does not attempt to answer:

How might one convert between systems at a boundary?
```
3 feet → ? metre (1/3.280839895...?) 
↺ Each iteration
```

Because for computation, this is quite flawed. It destroys certainty for implementation convenience.

```
Define unit frame → Define derived units → Work within it, not outside it.
```


## What is a Unit Frame?

A unit frame defines the dimensional system used by an application.
 
For example:
 
```text
[symbols]
time: s
length: m
mass: kg
current: A
temperature: K
amount: mol
luminosity: cd
dimensionless: ∅
```

The dimensional environment is independent of the notation used to represent it. Hence, any semantic representation can be used. However, PicoUnits operates on a fixed set of fundamental dimensions and prefixes.

See the [`.picounits`](https://github.com/Bowley-Systems/PicoUnits/blob/main/.picounits) file for implementation details.

## What are `.ut` and `.uiv`?

Both are dimensionally aware formats: `.ut` defines custom units, while `.uiv` encodes quantities as `value prefix(unit)` groups.

`.ut` defines the custom units for your unit system:
```
[units]
p: kg*m^-1*s^-2                # Defines the unit for pressure (Pascal)
```

`.uiv` defines the quantities within your unit system:

```
[model]
inlet_pressure: 101 k(p)  # 101 kPa using the defined unit p
```
See the [UnitValues repository](https://github.com/Bowley-Systems/UnitValues) for notation and language specification.

## Quick Start

A standard introduction example is available in [`example/`](https://github.com/wgbowley/PicoUnits/tree/main/example).

```py
from picounits import expects, VOLTAGE, CURRENT, RESISTANCE
 
@expects(VOLTAGE)
def ohm_law(i, r):
    return i * r
 
# Correct Usage
ohm_law(10 * CURRENT, 5 * RESISTANCE) 
# > Output: 50.0 (kg·m²·s⁻³·A⁻¹)

# Incorrect Usage
ohm_law(10 * CURRENT, 5 * VOLTAGE)
# > DimensionError: 'ohm_law' returned kg·m²·s⁻³, expected kg·m²·s⁻³·A⁻¹
```

## Installation 
 
To install:
```bash
pip install PicoUnits
```

### Documentation

Full documentation is available in the [`docs/`](https://github.com/wgbowley/PicoUnits/tree/main/docs) folder, including API reference, changelog, and contributors.
