Support for physical quantities with units, based on numpy
Quantities is designed to handle arithmetic and conversions of physical quantities, which have a magnitude, dimensionality specified by various units, and possibly an uncertainty. See the tutorial for examples. Quantities builds on the popular numpy library and is designed to work with numpy ufuncs, many of which are already supported. Quantities is actively developed, and while the current features and API are stable, test coverage is incomplete so the package is not suggested for mission-critical applications.
A Python package for handling physical quantities. The source code and issue tracker are hosted on GitHub:
Get the latest version of quantities from https://pypi.python.org/pypi/quantities/
To get the Git version do:
$ git clone git://github.com/python-quantities/python-quantities.git
Documentation and usage
You can find the official documentation at:
Here is a simple example:
>>> import quantities as pq >>> distance = 42*pq.metre >>> time = 17*pq.second >>> velocity = distance / time >>> "%.3f %s" % (velocity.magnitude, velocity.dimensionality) '2.471 m/s' >>> velocity + 3 Traceback (most recent call last): ... ValueError: Unable to convert between units of "dimensionless" and "m/s"
quantities has a hard dependency on the NumPy library. You should install it first, please refer to the NumPy installation guide:
To install quantities itself, then simply run:
$ pip install quantities
To execute all tests, install pytest:
$ python -m pip install pytest
in the current directory. The master branch is automatically tested by GitHub Actions.
Quantities only uses BSD compatible code. See the Open Source Initiative licenses page for details on individual licenses.
See doc/user/license.rst for further details on the license of quantities
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for quantities-0.14.1-py3-none-any.whl