Posts

Showing posts from December, 2013

Context aware unit conversion in Pint

Today I am releasing version 0.4 of Pint, a Python units library. Pint is Python package to define, operate and manipulate physical quantities: the product of a numerical value and a unit of measurement. It allows arithmetic operations between them and conversions from and to different units. It provides a comprehensive and extensive list of physical units, prefixes and constants defined in a standalone text file. The registry can parse prefixed and pluralized forms of units resulting in a much shorter and maintainable unit definition list. It also provides great NumPy integration, with implicit unit conversion and an emphasis on correctness. What's new Pint 0.4 introduces the concept of Context. A Context enables to convert between unrelated dimensions based on pre-established rules. For example, in spectroscopy you might require to convert between wavelength and frequency. As expected, Pint will raise an error if you try to do this:     >>> import pint     &