A light-weight wrapper around pint for unit conversions.
Project description
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 unitsto_u(value, to_units)
: Convert a value (or an iterable container of values) from base SI units to given unitsconvert(value, from_units, to_units)
: Convert a value (or an iterable container of values) from any units to another units of the same dimensionalityget_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
Built Distribution
File details
Details for the file koozie-1.2.3.tar.gz
.
File metadata
- Download URL: koozie-1.2.3.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e61b1eb3f7f8a4c231143a779b759bec2d7ddcaf3b2db3efad9c2cd0a9dd5379 |
|
MD5 | 2243aed8e325f2c2c633272718132106 |
|
BLAKE2b-256 | 83dae9d0fedaa7e5bc3c34f2f5796dcd66d4a77af50f9e58eee01586a2a2ff51 |
File details
Details for the file koozie-1.2.3-py3-none-any.whl
.
File metadata
- Download URL: koozie-1.2.3-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdd9a14e99bdd5c6317dac13f3aca85a72a2fe6dfaa78bf6a7db489332053063 |
|
MD5 | b5fea8c63ec09d6dce24433c1860b053 |
|
BLAKE2b-256 | b50eaf49c92838f3dac0eafaf32eba3d9caf211a0189d42985efec26ebf077b8 |