Skip to main content

Quantity-Value supports calculations with physical quantities

Project description

Documentation Status travis appveyor pypi

This package provides Python support for physical quantities used in mathematical equations.

Python objects called quantity-values are used to associate a measured value with a unit of measurement. Calculations involving these objects follow the rules of quantity calculus.

The package can be used to define the quantities, and associated units of measurement, of interest in a specific problem. In that way the context in which quantity calculations are performed is well defined.


Calculations involving electrical measurements can be described in terms of a simple set of base quantities, here we declare current and voltage and the dependent quantity resistance

>>> from QV import *
>>> context = Context( ("Current","I"),("Voltage","V") )
>>> Resistance = context.declare('Resistance','R','Voltage/Current')

Units can be declared in terms of these quantities

>>> ureg = UnitRegister("ureg",context)
>>> volt = ureg.reference_unit('Voltage','volt','V')
>>> amp = ureg.reference_unit('Current','amp','A')
>>> milliamp = prefix.milli(amp)
>>> ohm = ureg.reference_unit('Resistance','Ohm','Ohm')

and then quantity-values can be created and manipulated

>>> v1 = qvalue(0.10,volt)
>>> i1 = qvalue(15,milliamp)
>>> print( qresult( v1/i1 ) )
6.6666666666... Ohm


The Quantity-Value package is part of a research project at the Measurement Standards Laboratory of New Zealand looking at issues in Digital Metrology.

Quantity-Value is intended as an exemplar for software that supports the concept of a physical quantity and physical quantity calculations.

The project is on-going and should not yet be considered stable. There may be substantial changes in later versions.


The documentation for Quantity-Value can be found here.

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Quantity-Value, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size Quantity_Value-0.1.0-py2.py3-none-any.whl (20.6 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size Quantity-Value-0.1.0.tar.gz (17.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page