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.4-cp310-abi3-win_amd64.whl (798.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

si_units-0.11.4-cp310-abi3-win32.whl (719.0 kB view details)

Uploaded CPython 3.10+Windows x86

si_units-0.11.4-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.4-cp310-abi3-macosx_11_0_arm64.whl (907.3 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

si_units-0.11.4-cp310-abi3-macosx_10_12_x86_64.whl (948.2 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: si_units-0.11.4-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 798.7 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.4-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ad8bbd9360455036e8f3b6407350a0457981017796284de37822340e570723d9
MD5 f66185f07a49cb991361a50674fae8fd
BLAKE2b-256 3bbc3324e7515290dd0ca2486371959b74c8ade1cf63186f294d9150e65e0584

See more details on using hashes here.

File details

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

File metadata

  • Download URL: si_units-0.11.4-cp310-abi3-win32.whl
  • Upload date:
  • Size: 719.0 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.4-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 a5a307a4c489b53dcf8cc6aa0ed25a0c85d34028159212a8239d6c5d8301242e
MD5 e5c2943642141c9d4f3c7c0f85731510
BLAKE2b-256 aff5f88c43f4d1e8541394b1573ad91bdba093d9f9b2824f57574c801f78acef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for si_units-0.11.4-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 dbd76ffae022e60262ceab6fd5948271783c5b127de4f1fa303f8054bfd686c9
MD5 15c61de2878607367d4d4d0ec4a81721
BLAKE2b-256 8eb3e54f9b967e7f761ee1c331cb28947d18087438a53e29f66b398bfb7bb49d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for si_units-0.11.4-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4e2123579c778944e1c4551cb3d20458560028908b8bc6beb79635f5d52e6f99
MD5 3eed0b44f7c2fbccb6505538999a9b80
BLAKE2b-256 b92e2596d472e90ad528a389d041be0763b3547b458552ff0edb59ee44d79630

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for si_units-0.11.4-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5c6de4aa9ea2a2aa421d0c94047916c827b2c84428b9415bce300beee4d09faa
MD5 08458ff84d10d6f6db5e42325fbca715
BLAKE2b-256 dafcdbcbe57f5358a555443586c957e3cf1bf6ee1679cbd49414b2497bc6b65e

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