Metadata-Version: 2.4
Name: PicoUnits
Version: 0.0.1
Summary: SI Based Unit System With Minimal Overhead And Maximal Speed
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: high-performance,minimal,physics,si,units
Description-Content-Type: text/markdown

<p align="center">
  <img src="media/banner.png" alt="PicoUnits" style="max-width:600px;">
  <br>
  <em>SI Unit System Designed For Minimal Overhead  – Built with speed by <a href="https://github.com/wgbowley">William Bowley</a></em>
</p>

## Overview

![Work in Progress](https://img.shields.io/badge/status-wip-orange)
![Python Version](https://img.shields.io/badge/python-3.10+-blue)
![License](https://img.shields.io/badge/license-MIT-green)

**PicoUnits** is a low overhead library designed for ensuring dimensional accuracy during runtime. It uses a custom seven fundamental unit system based off the standard SI metric fundamental units. 

```py
class SIBase(Enum):
    """ SI metric fundamental units expect mass is defined as a gram """
    SECOND = auto()             # Time
    METER = auto()              # Length
    GRAM = auto()               # Mass
    AMPERE = auto()             # Electric Current
    KELVIN = auto()             # Temperature
    MOLE = auto()               # Amount of a substance
    CANDELA = auto()            # Luminous Intensity
    DIMENSIONLESS = auto()      # Non-physical quantity
```

Each unit is made up of a subclass called `Dimension` which itself is made of two sub-dataclasses `SIBase`, `PrefixScale` and one integer value `exponent`:

```py
@dataclass()
class Dimension:
    """
    Defines a SI metric dimension through 'SIBase', 'PrefixScale and 'exponent'
    """
    prefix: PrefixScale = PrefixScale.BASE
    base: SIBase = SIBase.DIMENSIONLESS
    exponent: int = 1

class Unit:
    """
    Defines a SI metric unit composed of a singular or multiple 'Dimension'.
    """
    def __init__(self, *dimensions: Dimension) -> None:
        self.dimensions = list(dimensions)
```



Each `Quantity` has both a magnitude and unit, and through the usage of dunder methods dimensional analysis happens in parallel with arithmetic operations.  

```py
@dataclass
class Quantity:
    """
    Represents a quantity within the framework with both magnitude and unit
    """
    magnitude: float | int
    unit: Unit
```

## Installation

PicoUnits requires Python 3.10 or newer.

```bash
pip install picounits
```
