Skip to main content

A light-weight wrapper around pint for unit conversions.

Project description

Release

Test

koozie

koozie is a light-weight wrapper around pint for unit conversions. The intent is to provide much of the functionality without worrying about the setup. It uses quantities internally, but its functions only return floats. This approach reflects the opinion that all calculations should be performed in Standard base SI units, and any conversions can happen via pre- or post-processing for usability. This minimizes additional operations in performance critical code.

koozie also defines a few convenient aliases for different units. See the source code for details. A list of other available units is defined in pint's default units definition file.

There are four public functions in koozie:

  • fr_u(value, from_units): Convert a value (or an iterable container of values) from given units to base SI units
  • to_u(value, to_units): Convert a value (or an iterable container of values) from base SI units to given units
  • convert(value, from_units, to_units): Convert a value (or an iterable container of values) from any units to another units of the same dimensionality
  • get_dimensionality(units): Get a dictionary-like representation of the dimensionality of units. This is useful for checking if two quantities can be converted to common units.

Example usage can be found in the test file.

koozie also provides a command line utility for unit conversions:

Usage: koozie [OPTIONS] VALUE FROM_UNITS [TO_UNITS]

  koozie: Convert VALUE from FROM_UNITS to TO_UNITS.

  If TO_UNITS is not specified, VALUE will be converted from FROM_UNITS into
  base SI units.

Options:
  -v, --version    Show the version and exit.
  -l, --list TEXT  Print a list of available units by dimension (e.g.,
                   "power"). Default: list all units.
  -h, --help       Show this message and exit.

Example usage:

$ koozie 1 inch meter
> 0.0254 m

$ koozie 0 degC degF
> 31.999999999999936 °F

$ koozie 0 degC
> 273.15 K

$ koozie -l flow
> [length] ** 3 / [time] ([volumetric_flow_rate])
  -----------------------------------------------
    - cubic_feet_per_minute (cfm)
    - gallons_per_minute (gpm)

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

koozie-1.3.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

koozie-1.3.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file koozie-1.3.0.tar.gz.

File metadata

  • Download URL: koozie-1.3.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for koozie-1.3.0.tar.gz
Algorithm Hash digest
SHA256 cd9b749482b7769a7b9c2c4965a48f4c1d23d8b9ecd8ae5b18f708f9822b7e92
MD5 31088abf5e78896f20657b58b4c53baf
BLAKE2b-256 1dfa5b3f2561010396db239237c26ce48dfe07513dd60a7d80dcc9ce43e056c2

See more details on using hashes here.

File details

Details for the file koozie-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: koozie-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for koozie-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e0217f5a12a33a51ec755f21461f3926430f5b2426e53d38fc679554806dded
MD5 b5f0b1fdfaddeeb0461d87ce119768ce
BLAKE2b-256 861ef30954b7cb2dfa14d4e343ae95b5bc786a43042efb547af06c19f0a47789

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