Skip to main content

Representation of quantites, i.e. of unit valued scalars and arrays.

Project description

si-units

documentation PyPI version

Representation of quantities with SI units.

The package is written with flexibility in mind and is able to represent arbitrarily complex units. In addition to simple scalar quantities, it can be used to decorate any complex data type (numpy arrays, PyTorch tensors) to provide unit checks.

Installation and Usage

You can install the package from PyPI

pip install si-units

For the documentation, see here.

To build the wheel or documentation locally, see below.

Examples

Calculate the pressure of an ideal gas.

from si_units import *
temperature = 25.0 * CELSIUS
volume = 1.5 * METER**3
moles = 75.0 * MOL
pressure = moles * RGAS * temperature / volume
print(pressure) # 123.94785148011941 kPa

numpy functions can be used with SI units:

from si_units import *
import numpy as np
ms = np.linspace(2.0, 4.0, 3) * METER
sqms = ms**2
print(sqms) # [4, 9, 16] m²

Building from Source

You need a rust compiler to build the wheel locally. To build the bindings to python, we use maturin.

Use

# in si-units
maturin develop --release

to build the package locally.

To build the python wheels, use

maturin build --release

Building the Documentation

To build the documentation you need mkdocs-material and mkdocstrings-python. Installing these packages (e.g. using uv or pip) will also install the needed dependencies. During development, use

# in si-units
mkdocs serve

to run a local development server.

To build the documentation for deployment, use

# in si-units
mkdocs build

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

si_units-0.11.2-cp310-abi3-win_amd64.whl (794.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

si_units-0.11.2-cp310-abi3-win32.whl (717.5 kB view details)

Uploaded CPython 3.10+Windows x86

si_units-0.11.2-cp310-abi3-manylinux_2_34_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

si_units-0.11.2-cp310-abi3-macosx_11_0_arm64.whl (906.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

si_units-0.11.2-cp310-abi3-macosx_10_12_x86_64.whl (956.5 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file si_units-0.11.2-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: si_units-0.11.2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 794.4 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for si_units-0.11.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 758ae40c55bdb1368bf7743794050639408052f21d11d389b12caa1c3bc815db
MD5 e708537868950f9a5405ae6a9ad4e22b
BLAKE2b-256 e8739c2e465b7f0eacf4bca0e36570e75f9c2a473d69a21ce7e99c4c7036da2e

See more details on using hashes here.

File details

Details for the file si_units-0.11.2-cp310-abi3-win32.whl.

File metadata

  • Download URL: si_units-0.11.2-cp310-abi3-win32.whl
  • Upload date:
  • Size: 717.5 kB
  • Tags: CPython 3.10+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for si_units-0.11.2-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 3fa5a5511ed45b1309293946a0bcf5e7e7bc1058008204f3b1a807c54007acec
MD5 0bc6ebb3332521b4773c7bf18be21975
BLAKE2b-256 949e5605a1d421cd89d4786558f886ab1dfb754be8c7a4bdcc28be4ca8dea7ca

See more details on using hashes here.

File details

Details for the file si_units-0.11.2-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for si_units-0.11.2-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 167942554f6d9a5f44572c9dac27961c7cf7592e835b5ddcd618861bb4903cb4
MD5 ebe704d7ef7d3edbacb23ef4ad33b5cf
BLAKE2b-256 65c99bc6abdc600a863b1ae6aebefe38372a04ee432f88a5bb27b2e36379ff8b

See more details on using hashes here.

File details

Details for the file si_units-0.11.2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for si_units-0.11.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a79bd68f0b598a3a6236c53cfdccf62f309bc6a3f51e29c3be4c26509d464f37
MD5 6c655c209883c17b170218db5aad03c2
BLAKE2b-256 e35d57f5d5405412954375f8b90696d2dab9a1c90455dc8c42d3e291978e6fed

See more details on using hashes here.

File details

Details for the file si_units-0.11.2-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for si_units-0.11.2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 99b68dd3044932d9ff158cec3c55577f15445dbd6978261ecd0ae43ca2603668
MD5 a97595ce3f4b20a4c74b6d3339d73d37
BLAKE2b-256 02b1247bcef7f9cf34a2a0cdee5adcfc7590dadb58d8f1b08dbf07b26b181d1c

See more details on using hashes here.

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