pypbomb.units
Extra unit management tools for pint quantities
- pypbomb.units.check_pint_quantity(quantity, dimension_type, ensure_positive=False)
Checks to make sure that a quantity is an instance of a pint quantity, and that it has the correct units. Currently supported dimension types:
"length"
"area"
"volume"
"temperature"
"pressure"
"velocity"
"density"
- Parameters:
quantity (pint.Quantity) – Pint quantity which is to be checked for dimensionality
dimension_type (str) – Dimensionality that quantity should have
ensure_positive (bool) – Determines whether the magnitude of the pint quantity will be checked for positivity
- Returns:
True if no errors are raised
- Return type:
bool
- pypbomb.units.parse_quant_input(quant_input, unit_registry)
Converts a tuple of
(magnitude, "units")
to a pint quantity or converts a pint quantity to the local registry.- Parameters:
quant_input (pint.Quantity or tuple) – Iterable or quantity to be parsed
unit_registry (pint.UnitRegistry) – Unit registry to be used for pint quantities
- Returns:
Input as a pint quantity
- Return type:
pint.Quantity