Representation of quantites, i.e. of unit valued scalars and arrays.
Project description
si-units
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file si_units-0.11.1-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: si_units-0.11.1-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 796.6 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a93cf1b1f49c3c2112452904d755714fd2b9b5ec334aa4e3e25e08e5f2e80def
|
|
| MD5 |
d22f5a2283904068da447c53d7b9672c
|
|
| BLAKE2b-256 |
35f052e43d47c83b5309c88670b2f569d775d61e71b9ea3517c758f74601bc3b
|
File details
Details for the file si_units-0.11.1-cp310-abi3-win32.whl.
File metadata
- Download URL: si_units-0.11.1-cp310-abi3-win32.whl
- Upload date:
- Size: 713.7 kB
- Tags: CPython 3.10+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b282ff0c42f82c622023cdbd1422153fb2aaef945fff7eb3732c61042252368b
|
|
| MD5 |
299af9c5ddd1462655e3f05e8301efbf
|
|
| BLAKE2b-256 |
049fbe677aa255a42c45e066967f1d842bce743309f0aefdb3ac9951ee545b34
|
File details
Details for the file si_units-0.11.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: si_units-0.11.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46f7624741b67f86c5a9a98560b495c9d74f9530f3b134ce85c2dda5584b40e0
|
|
| MD5 |
3ddf08f7c32bd8821a2a65a28a420bd4
|
|
| BLAKE2b-256 |
389a145b4f9a8f31b2a5c4721065b96a37b6401261423f73ac4856167f57c5c9
|
File details
Details for the file si_units-0.11.1-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: si_units-0.11.1-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 901.2 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb2cfedc6bb32832abf1ac8c9237d2890b711dffa337790df87da2243efa7a16
|
|
| MD5 |
52b193355482441239611ce07a4d8bcf
|
|
| BLAKE2b-256 |
096fe4e4d8eb137d614e36a1b9fb5fa527e9e8f2a38d3c54abe2cfc0ebaf89b9
|
File details
Details for the file si_units-0.11.1-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: si_units-0.11.1-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 960.9 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10e326a7e3da4e695041d226af1cb4b2a696ad6afaac73da06b359baee9f5d04
|
|
| MD5 |
1a4fc9f9b2f858d08a94fcae2ad49ed8
|
|
| BLAKE2b-256 |
05997790ced04da02792b911ff32a43ddcddaa827015dcdf5f232f631dee23de
|