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

Uploaded CPython 3.10+Windows x86-64

si_units-0.11.3-cp310-abi3-win32.whl (717.9 kB view details)

Uploaded CPython 3.10+Windows x86

si_units-0.11.3-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.3-cp310-abi3-macosx_11_0_arm64.whl (907.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

si_units-0.11.3-cp310-abi3-macosx_10_12_x86_64.whl (957.6 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: si_units-0.11.3-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 795.2 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.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 acf78779ab7bbd597dce38eb3d3c9ab0a379eeca10fa83dd234aa84e56522b76
MD5 38bd9c6841995377bf58e33cb7720268
BLAKE2b-256 7fa4c0d4b8d22834ed210a48972be5d60e22120f78eb7587ff53900783267775

See more details on using hashes here.

File details

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

File metadata

  • Download URL: si_units-0.11.3-cp310-abi3-win32.whl
  • Upload date:
  • Size: 717.9 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.3-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 7a4abf0fbb1062d35fce4a3c7b9b740335062b17fae52256e05975de1ec4c3ef
MD5 53b32ef472dd8a86b1fdcdbdc0f7225c
BLAKE2b-256 b42c60aca981ad80824667b7c5f38a2d455b5ec50b7b910cec6c860e564f1b4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for si_units-0.11.3-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b27c85c77b816f7ba96b3fa3b9ea336ddbf981a424989523cb7c33b8a30e94a3
MD5 82eada15e8d7208ebfcd753dc7440168
BLAKE2b-256 1f44ca99638f7ed75eb65239171b1aae7dc858fa0d09de3baa09be22a0952988

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for si_units-0.11.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35b1ed748b3c93684961f110aa06904c8c09f97adb8525b36efd5c090f228f42
MD5 c8cb027612f16f7c5a904af4c5a6fba4
BLAKE2b-256 64e387d52ccfde47c069f446a71c615e92d1d2dfa5c3e3701b6015ddccc08cff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for si_units-0.11.3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ec7ce1795bf31eae46e1cf353410c9a64200f1c84f2ccc3b8d2d7b3e61a39318
MD5 843f4d29a404ac4647a48149723ebd1e
BLAKE2b-256 76ba38cc08f163acbd0666b5fb79e8d5419cf4a82beb86e5941f94b1492c0316

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