Skip to main content

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.

pypi version Build status

A Python package for handling physical quantities. The source code and issue tracker are hosted on GitHub:

https://www.github.com/python-quantities/python-quantities

Download

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:

http://python-quantities.readthedocs.io/

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"

Installation

quantities has a hard dependency on the NumPy library. You should install it first, please refer to the NumPy installation guide:

http://docs.scipy.org/doc/numpy/user/install.html

To install quantities itself, then simply run:

$ pip install quantities

Tests

To execute all tests, install pytest:

$ python -m pip install pytest

And run:

$ pytest

in the current directory. The master branch is automatically tested by GitHub Actions.

Author

quantities was originally written by Darren Dale, and has received contributions from many people.

License

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

Metadata

Release files for quantities 0.14.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quantities 0.14.1
File Size Uploaded
quantities-0.14.1.tar.gz 91.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for quantities 0.14.1
File Interpreter ABI Platform
quantities-0.14.1-py3-none-any.whl Python 3 none any Details

Total release size: 179.5 kB

Release files / quantities-0.14.1.tar.gz

Download URL quantities-0.14.1.tar.gz
Size 91.5 kB
Tags Source
SHA-256 checksum
How to use checksums
efeafffc0c0364f891a9327239cd12496bccb55cd037a6d1bf44de706f722877
BLAKE2b-256 checksum
How to use checksums
728351a5cad60b4c1fa64187d0ab6d8048ad1347b678e9dff5b42d045b2083c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release files / quantities-0.14.1-py3-none-any.whl

Download URL quantities-0.14.1-py3-none-any.whl
Size 87.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2edf67b8c2a28aa3bbe096f9fc3ec3ab83fc3192997373641cddab32bea2f72
BLAKE2b-256 checksum
How to use checksums
d887d5042d2a7b689a1bd69d9d37ec19c60d97f29c9009fc47500e41ac27e20e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release history Release notifications | RSS feed

0.16.4

2 release files

0.16.3

2 release files

0.16.2

2 release files

0.16.1

2 release files

0.16.0

2 release files

This release

0.14.1 This release

2 release files

0.13.0

1 release file

0.12.5

1 release file

0.12.4

1 release file

0.12.3

1 release file

0.12.2

1 release file

0.12.1

1 release file

0.12.0

1 release file

0.11.1

1 release file

0.11.0

1 release file

0.10.1

2 release files

0.10.0

2 release files

0.9.0

8 release files

0.8.0

2 release files

0.7.0

5 release files

0.6.0

4 release files

0.5.2

4 release files

0.5.1

3 release files

0.5.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page