Skip to main content

A package for dimensional analysis calculations on floating-point values

Project description

Unitscalar: real-time verified dimensional analysis in Python

Basic validation

This package implements a unit-aware number data type that keeps track of units as an inseparable part of the number. Heavily inspired by Steve Byrnes' numericalunits

Valid Literals

UnitScalar uses custom-literals to hack support for custom literals into the language. These are defined for certain (arbitrary) unit strings as needed. At present:

Literal Unit String Example
x "" (N/A) 10 .x or 10.x
gMM g/mol 101.1.gMM
inch in 3.90.inch
psi psi 10.0.psi
lbf lbf 0.0.lbf
K K 1837.22.K

As a consequence of including this feature, unitscalar depends on the PIP package custom_literals. The latter mentioned warning about stability shouldn't affect downstream projects if the literals feature is not used.

Fair Warning

Briefly quoting the custom-literals README section on stability caveats:

This library relies almost entirely on implementation-specific behavior of the CPython interpreter. It is not guaranteed to work on all platforms, or on all versions of Python. It has been tested on common platforms (windows, ubuntu, macos) using python 3.7 through to 3.10, but while changes that would break the library are quite unlikely, they are not impossible either.

TODO List

  • Implement convert_to_units for output in another format (e.g. A to uA or N to lbf)
  • Vectorized artithmetic?
  • Write example code and fill out README

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unitscalar-0.0.6.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unitscalar-0.0.6-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file unitscalar-0.0.6.tar.gz.

File metadata

  • Download URL: unitscalar-0.0.6.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for unitscalar-0.0.6.tar.gz
Algorithm Hash digest
SHA256 d029a9d19192d9f07245ae2c2ca4b086b28bb7af1ec6a35e6da314032b0c7f3e
MD5 0e4b511464d213b4f8fb2f7681ccbd8f
BLAKE2b-256 c9af3879de6218d7785b5558304d3227eedcca1e7f001c5feb6a918df2e33222

See more details on using hashes here.

File details

Details for the file unitscalar-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: unitscalar-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for unitscalar-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 cd237d3a56873ea4a837351983f77a13e17afc733e3e6570947c16a8df3888b3
MD5 f03fee239eb73ca88056da12d98f0aee
BLAKE2b-256 a34e03833e75d7235ebafbd3e1fc5b4c383dd7ed414a92c42c6626f1a70d5edf

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