pyunitwizard.quantity#
- pyunitwizard.quantity(value, unit=None, form=None, parser=None, standardized=False)[source]#
Returns a quantity.
- Parameters:
value (int, float or arraylike) – The value of the quantity. Can be a scalar or an array like type.
unit (UnitLike) – Unit in of the quantity in any of the accepted form.
form ({"unyt", "pint", "openmm.unit", "astropy.units", "openff.units", "string"}, optional) – Output form of the quantity.
parser ({"unyt", "pint", "openmm.unit", "astropy.units"}, optional) – The parser to use.
standardized (bool, optional) – Return a standardized quantity, default=False.
- Returns:
The quantity.
- Return type:
QuantityLike
- Raises:
UnsupportedRepresentationError – The selected backend refuses a NumPy object array of numeric rows.
Notes
Direct construction from an object array of numeric NumPy rows retains the row buffers in Pint, OpenMM, unyt and OpenFF. Conversion capabilities depend on the backend; Astropy refuses this representation. Use flat numeric values and CSR offsets for portable variable-length data.
Examples
>>> get_value(quantity(2.0, "nm", form="pint", parser="pint")) 2.0