Metadata-Version: 2.5
Name: PicoUnits
Version: 1.1.3
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 -> deep, muted teal-green 
#d92c2aff -> bold, warm crimson-red 

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 `▽`ʃ♡
-->

<p align="center">
  <img 
    src="https://raw.githubusercontent.com/Bowley-Systems/PicoUnits/refs/heads/main/media/logo.png" 
    alt="PicoUnits logo" 
    width="100%" 
    style="max-width:100%; display:block;"
  >
</p>

<p align="center">
    <strong>Define the type. Define the variable. Execute.</strong>
    <br>
    Automate physical meaning throughout your pipeline.
</p>


### Overview

![Version](https://img.shields.io/badge/Version-1.1.3-006D77?style=flat-square)
![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-80%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)

<b>Picounits</b> is a dynamic runtime typing system for numerical dimensional quantities. 
It provides a consistent type system for expressing dimensional quantities throughout your pipeline.

### 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 with type-specific operations.
- Traces quantity construction and dimensional operations performed on quantities.
- Type checking at functional boundaries, defined by the user.
```

---

### Why convert at all?

<b>Picounits</b> reduces complexity by reducing the set of units to one canonical set defined by the user.

<strong>It does not attempt to answer:</strong>

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

<b>Picounits</b> follows this principle:

```
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. <br>
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:

```
attribute: value prefix(unit)
```

<br>

`.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
```

<br>

See [`UnitValues`](https://github.com/Bowley-Systems/UnitValues) for overview and language specification.

---

### Quick Start

A step-by-step introduction is available in [`tutorial/`](https://github.com/Bowley-Systems/PicoUnits/tree/main/tutorial). <br>

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

# Incorrect Usage
myVar = 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/Bowley-Systems/PicoUnits/tree/main/docs) folder including API reference, changelog, and contributors.

---
