# si-units
[![documentation](https://img.shields.io/badge/docs-github--pages-blue)](https://itt-ustutt.github.io/quantity/index.html)
[![PyPI version](https://badge.fury.io/py/si_units.svg)](https://badge.fury.io/py/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](https://itt-ustutt.github.io/quantity/index.html).
To build the wheel or documentation locally, see below.
## Examples
Calculate the pressure of an ideal gas.
```python
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:
```python
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](https://github.com/PyO3/maturin).
Use
``` bash
# in si-units
maturin develop --release
```
to build the package locally.
To build the python wheels, use
```bash
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
```bash
# in si-units
mkdocs serve
```
to run a local development server.
To build the documentation for deployment, use
```bash
# in si-units
mkdocs build
```
Raw data
{
"_id": null,
"home_page": "https://github.com/itt-ustutt/quantity/tree/master/si-units",
"name": "si-units",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "physics, units, SI",
"author": "Philipp Rehner <prehner@ethz.ch>, Gernot Bauer <bauer@itt.uni-stuttgart.de>",
"author_email": "Philipp Rehner <prehner@ethz.ch>, Gernot Bauer <bauer@itt.uni-stuttgart.de>",
"download_url": null,
"platform": null,
"description": "# si-units\n\n[![documentation](https://img.shields.io/badge/docs-github--pages-blue)](https://itt-ustutt.github.io/quantity/index.html)\n[![PyPI version](https://badge.fury.io/py/si_units.svg)](https://badge.fury.io/py/si_units)\n\nRepresentation of quantities with SI units.\n\nThe package is written with flexibility in mind and is able to represent arbitrarily complex units.\nIn addition to simple scalar quantities, it can be used to decorate any complex data type (numpy arrays, PyTorch tensors) to provide unit checks.\n\n## Installation and Usage\n\nYou can install the package from PyPI\n\n```\npip install si-units\n```\n\nFor the documentation, see [here](https://itt-ustutt.github.io/quantity/index.html).\n\nTo build the wheel or documentation locally, see below.\n\n## Examples\n\nCalculate the pressure of an ideal gas.\n\n```python\nfrom si_units import *\ntemperature = 25.0 * CELSIUS\nvolume = 1.5 * METER**3\nmoles = 75.0 * MOL\npressure = moles * RGAS * temperature / volume\nprint(pressure) # 123.94785148011941 kPa\n```\n\n`numpy` functions can be used with SI units:\n\n```python\nfrom si_units import *\nimport numpy as np\nms = np.linspace(2.0, 4.0, 3) * METER\nsqms = ms**2\nprint(sqms) # [4, 9, 16] m\u00b2\n```\n\n## Building from Source\n\nYou need a rust compiler to build the wheel locally.\nTo build the bindings to python, we use [maturin](https://github.com/PyO3/maturin).\n\nUse\n\n``` bash\n# in si-units\nmaturin develop --release\n```\n\nto build the package locally.\n\nTo build the python wheels, use\n\n```bash\nmaturin build --release\n```\n\n## Building the Documentation\n\nTo 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. \nDuring development, use\n\n```bash\n# in si-units\nmkdocs serve\n```\n\nto run a local development server.\n\nTo build the documentation for deployment, use\n\n```bash\n# in si-units\nmkdocs build\n```\n\n\n",
"bugtrack_url": null,
"license": "MIT OR Apache-2.0",
"summary": "Representation of quantites, i.e. of unit valued scalars and arrays.",
"version": "0.11.0",
"project_urls": {
"Homepage": "https://github.com/itt-ustutt/quantity/tree/master/si-units",
"Source Code": "https://github.com/itt-ustutt/quantity"
},
"split_keywords": [
"physics",
" units",
" si"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "36a5efe6e95284c4030fdbc22e48a7826f33f82087be09b503894aa170d9b641",
"md5": "ac517136ed0ca7dcdeede88c5549c63e",
"sha256": "a626e1d15b7cded6a2775eb0b0a99010e10232df57250b3cf17657354ba996ac"
},
"downloads": -1,
"filename": "si_units-0.11.0-cp39-abi3-macosx_10_12_x86_64.whl",
"has_sig": false,
"md5_digest": "ac517136ed0ca7dcdeede88c5549c63e",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 947267,
"upload_time": "2024-12-28T14:17:59",
"upload_time_iso_8601": "2024-12-28T14:17:59.186437Z",
"url": "https://files.pythonhosted.org/packages/36/a5/efe6e95284c4030fdbc22e48a7826f33f82087be09b503894aa170d9b641/si_units-0.11.0-cp39-abi3-macosx_10_12_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "eb369279af643999030da18c727f72da96834b2b09d7f61c307531cba8a5716b",
"md5": "e6c7ea0593db487a695b81d5e3f5d943",
"sha256": "5313899dcafcd7cce45fba37b92e9781893026ddf33439f9a659b3f96271ef45"
},
"downloads": -1,
"filename": "si_units-0.11.0-cp39-abi3-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "e6c7ea0593db487a695b81d5e3f5d943",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 888813,
"upload_time": "2024-12-28T14:18:01",
"upload_time_iso_8601": "2024-12-28T14:18:01.848372Z",
"url": "https://files.pythonhosted.org/packages/eb/36/9279af643999030da18c727f72da96834b2b09d7f61c307531cba8a5716b/si_units-0.11.0-cp39-abi3-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ef1f418e856a7b73ee93ba08d47cdfab9fa3670190ee88cbbcfec14d534c3313",
"md5": "872e94a715499d83f71734711eb56f38",
"sha256": "36bcd77faad6cbde5753c20770790712caf8140eacf51435d11ac159ca03218e"
},
"downloads": -1,
"filename": "si_units-0.11.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "872e94a715499d83f71734711eb56f38",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 1065229,
"upload_time": "2024-12-28T14:18:04",
"upload_time_iso_8601": "2024-12-28T14:18:04.659850Z",
"url": "https://files.pythonhosted.org/packages/ef/1f/418e856a7b73ee93ba08d47cdfab9fa3670190ee88cbbcfec14d534c3313/si_units-0.11.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ce9f546a32c9314e61077544befd0d36ca4abf6a502254e2fe4e58a98f44a5f9",
"md5": "7e993aa8019f5d1a4458fd77008b1644",
"sha256": "e2bda9198095f0dc4279ceda473ed8816611eca34eea350a610a1196a70ddb87"
},
"downloads": -1,
"filename": "si_units-0.11.0-cp39-abi3-win32.whl",
"has_sig": false,
"md5_digest": "7e993aa8019f5d1a4458fd77008b1644",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 713895,
"upload_time": "2024-12-28T14:18:07",
"upload_time_iso_8601": "2024-12-28T14:18:07.241061Z",
"url": "https://files.pythonhosted.org/packages/ce/9f/546a32c9314e61077544befd0d36ca4abf6a502254e2fe4e58a98f44a5f9/si_units-0.11.0-cp39-abi3-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b79d9b7ebd436af10685bbb9e9e913e490b2bcac46570903ba9e700820e75680",
"md5": "953004e20d76ea09f8574656414121bb",
"sha256": "db1150584f0916e53c92f615da6609bf22a1035ff66d861637a144473e38d607"
},
"downloads": -1,
"filename": "si_units-0.11.0-cp39-abi3-win_amd64.whl",
"has_sig": false,
"md5_digest": "953004e20d76ea09f8574656414121bb",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 780510,
"upload_time": "2024-12-28T14:18:09",
"upload_time_iso_8601": "2024-12-28T14:18:09.813188Z",
"url": "https://files.pythonhosted.org/packages/b7/9d/9b7ebd436af10685bbb9e9e913e490b2bcac46570903ba9e700820e75680/si_units-0.11.0-cp39-abi3-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-28 14:17:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "itt-ustutt",
"github_project": "quantity",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "si-units"
}