The `measurement` library (also known as `python-measurement`) provides easy-to-use unit-aware measurement objects in Python. It allows for manipulation and conversion between various SI, US, and Imperial units for quantities like Distance, Weight, Volume, Temperature, Energy, Speed, and Time. The library is currently active, with its latest release (3.2.2) on January 10, 2023, and maintains a stable API.
pip install measurementVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating measurement objects, performing basic arithmetic, and converting between different units.
Be aware of the inherent limitations of floating-point arithmetic. For high-precision scientific or engineering applications, consider libraries designed for arbitrary-precision arithmetic or interval arithmetic if uncertainty propagation is critical.
Thoroughly test custom `MeasureBase` implementations, especially their interaction with `STANDARD_UNIT` and the `UNITS` dictionary. If preserving the original input unit is crucial, store it alongside the measurement object or use `measurement.utils.guess` to infer the unit upon retrieval where possible.
Install the library using pip: `pip install python-measurement`
Consult the library's documentation to verify supported units for the specific measure (e.g., Distance, Weight, Temperature) or check for typos. If the unit exists, ensure it's accessible as an attribute.
Ensure that arithmetic operations are only performed between measurement objects of compatible dimensions. If you need to combine values of different types, consider their physical relevance and handle them separately or convert them to a common comparable base if meaningful (e.g., energy from mass-energy equivalence).
Initialize measurement objects using a keyword argument where the keyword is the unit and its value is the quantity, for example: `from measurement.measures import Distance; d = Distance(km=10)`
Use a valid unit string recognized by the 'measurement' library. Check the library's documentation for the list of supported units and their correct abbreviations or full names.
No dependency data recorded yet.