Skip to main content

D-SI Units

A Python library for parsing, validating, and performing mathematical operations on SI units using the D-SI (Digital SI) and BIPM-RP (SI Reference Point) syntax.

The library allows:

  • Unit Parsing & Validation: Parse units from D-SI and BIPM-RP notation strings
  • Mathematical Operations: Perform multiplication, division, and power operations on units while preserving dimensional consistency
  • Multiple Output Formats: Convert units to LaTeX, UTF-8, and SIRP representations
  • Scale Factor Calculations: Calculate conversion factors between compatible units
  • Base Unit Conversions: Convert complex units to their base SI unit representation

The Javascript version of this library has moved to https://gitlab1.ptb.de/digitaldynamicmeasurement/dsiunits-js/

Installation

pip install dsiUnits

Requirements: Python 3.9+

Quick Start

from dsi_unit import DsiUnit

# Create units from D-SI notation
meter = DsiUnit(r"\metre")
second = DsiUnit(r"\second")
kilogram = DsiUnit(r"\kilogram")

# Or from BIPM-RP notation
velocity = DsiUnit("m.s-1")  # meters per second

Usage Examples

Basic Unit Operations

from dsi_unit import DsiUnit

# Mathematical operations
velocity = DsiUnit(r"\metre") / DsiUnit(r"\second")
print(velocity)  # \metre\per\second

acceleration = velocity / DsiUnit(r"\second")
print(acceleration)  # \metre\per\second\tothe{2}

force = DsiUnit(r"\kilogram") * acceleration
print(force)  # \kilogram\metre\per\second\tothe{2}

# Power operations
area = DsiUnit(r"\metre") ** 2
print(area)  # \metre\tothe{2}

Unit Conversions

# Check if units are scalable (convertible)
joule = DsiUnit(r"\joule")
watt_second = DsiUnit(r"\watt") * DsiUnit(r"\second")
print(joule.is_scalable(watt_second))  # True

# Get scale factor between compatible units
km = DsiUnit(r"\kilo\metre")
m = DsiUnit(r"\metre")
scale = km.get_scale_factor(m)  # 0.001 (1 km = 1000 m, so 1 km * 0.001 = 1 m)

# Convert to base units
newton = DsiUnit(r"\newton")
base = newton.to_base_unit_tree()
print(base)  # \kilogram\metre\per\second\tothe{2}

Output Formats

unit = DsiUnit(r"\kilo\metre\tothe{2}\per\second")

# LaTeX representation
print(unit.to_latex())  # $$\frac{\mathrm{k}\mathrm{m}^{2}}{\mathrm{s}}$$

# UTF-8 representation
print(unit.to_utf8())  # km²/s

# SIRP (SI Reference Point) representation
print(unit.to_sirp())  # km2.s-1

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Metadata

Release files for dsiUnits 3.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dsiUnits 3.1.4
File Size Uploaded Provenance Actions
dsiunits-3.1.4.tar.gz 56.0 kB Without provenance Details for dsiunits-3.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dsiUnits 3.1.4
File Interpreter ABI Platform Actions
dsiunits-3.1.4-py3-none-any.whl Python 3 none any Details for dsiunits-3.1.4-py3-none-any.whl

Total release size: 100.8 kB

Release files / dsiunits-3.1.4.tar.gz

Download URL dsiunits-3.1.4.tar.gz
Size 56.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a8248cf94adbf9c67e4e5c1229a3402cb73a38ed5c7ffb7cf15d6b83d605cc4e
BLAKE2b-256 checksum
How to use checksums
b194f5aab161314b482f17e84bd266e2993afaed2c1c59fd30581fb80af363b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / dsiunits-3.1.4-py3-none-any.whl

Download URL dsiunits-3.1.4-py3-none-any.whl
Size 44.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6c20742964817b923bf54741c7c9067e2733cc041854b6e1e3184355ed3f997
BLAKE2b-256 checksum
How to use checksums
ed335733005d5a6c692520e3865ef5b8276eccb27f13526a45402fa4552be8e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for dsiUnits 3.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page