Skip to main content

SI Based Unit System With Minimal Overhead And Maximal Speed

Project description

PicoUnits
SI Unit System Designed For Minimal Overhead – Built with speed by William Bowley

Overview

Work in Progress Python Version License

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.

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:

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

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

pip install picounits

Project details


Download files

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

Source Distribution

picounits-0.0.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

picounits-0.0.1-py2.py3-none-any.whl (3.6 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: picounits-0.0.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for picounits-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0555aa30a56952c3eae7b92cc45675537f9fe019183e4dc58f3ace46d00895e6
MD5 2626ed9c606612b86c57487f40e3c5dc
BLAKE2b-256 97a309450812e5b251b1a40308b48355b9e6dcdee40284f62fc8c93dd687521b

See more details on using hashes here.

Provenance

The following attestation bundles were made for picounits-0.0.1.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-0.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: picounits-0.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for picounits-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d1b65f55c4330130b238ff830ce8e40488d85a642c4c4783646d04d9f1e68324
MD5 15b082751a299dd18e208e8923d9578f
BLAKE2b-256 8bf05780eed4e58207d4cf7ca6882fd7c634c34d92eee4e29c56fee2377a2c45

See more details on using hashes here.

Provenance

The following attestation bundles were made for picounits-0.0.1-py2.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.

Supported by

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