units package

The unit system.

Exported members: pamp, namp, uamp, mamp, amp, kamp, Mamp, Gamp, Tamp, kilogram, pmetre, nmetre, umetre, mmetre, metre, kmetre, Mmetre, Gmetre, Tmetre, pmeter, nmeter, umeter, mmeter, meter, kmeter ... (174 more members)

allunits module


Instead edit the template:


Exported members: metre, meter, gram, second, amp, kelvin, mole, candle, gramme, kilogram, radian, steradian, hertz, newton, pascal, joule, watt, coulomb, volt, farad, ohm, siemens, weber, tesla, henry ... (1991 more members)

fundamentalunits module

Defines physical units and quantities

Quantity Unit Symbol
Length metre m
Mass kilogram kg
Time second s
Electric current ampere A
Temperature kelvin K
Quantity of substance mole mol
Luminosity candle cd

Exported members: DimensionMismatchError, get_or_create_dimension(), get_dimensions(), is_dimensionless(), have_same_dimensions(), in_unit(), in_best_unit(), Quantity, Unit, register_new_unit(), check_units(), is_scalar_type(), get_unit(), get_unit_fast(), unit_checking


Dimension(dims) Stores the indices of the 7 basic SI unit dimension (length, mass, etc.).
DimensionMismatchError(description, *dims) Exception class for attempted operations with inconsistent dimensions.
Quantity A number with an associated physical dimension.
Unit(value[, dim, scale]) A physical unit.
UnitRegistry() Stores known units for printing in best units.


all_registered_units(*regs) Generator returning all registered units.
check_units(**au) Decorator to check units of arguments passed to a function
fail_for_dimension_mismatch(obj1[, obj2, ...]) Compare the dimensions of two objects.
get_dimensions(obj) Return the dimensions of any object that has them.
get_or_create_dimension(*args, **kwds) Create a new Dimension object or get a reference to an existing one.
get_unit(x, *regs) Find the most appropriate consistent unit from the unit registries.
get_unit_fast(x) Return a Quantity with value 1 and the same dimensions.
have_same_dimensions(obj1, obj2) Test if two values have the same dimensions.
in_best_unit(x[, precision]) Represent the value in the “best” unit.
in_unit(x, u[, precision]) Display a value in a certain unit with a given precision.
is_dimensionless(obj) Test if a value is dimensionless or not.
is_scalar_type(obj) Tells you if the object is a 1d number type.
quantity_with_dimensions(floatval, dims) Create a new Quantity with the given dimensions.
register_new_unit(u) Register a new unit for automatic displaying of quantities
unregister_unit(u) Remove a previously registered unit for automatic displaying of
wrap_function_change_dimensions(func, ...) Returns a new function that wraps the given function func so that it changes the dimensions of its input.
wrap_function_dimensionless(func) Returns a new function that wraps the given function func so that it raises a DimensionMismatchError if the function is called on a quantity with dimensions (excluding dimensionless quantitities).
wrap_function_keep_dimensions(func) Returns a new function that wraps the given function func so that it keeps the dimensions of its input.
wrap_function_remove_dimensions(func) Returns a new function that wraps the given function func so that it removes any dimensions from its input.


DIMENSIONLESS The singleton object for dimensionless Dimensions.
additional_unit_register UnitRegistry containing additional units (newton*metre, farad / metre, ...)
standard_unit_register UnitRegistry containing all the standard units (metre, kilogram, um2...)
user_unit_register UnitRegistry containing all units defined by the user

stdunits module

Optional short unit names

This module defines the following short unit names:

mV, mA, uA (micro_amp), nA, pA, mF, uF, nF, mS, uS, ms, Hz, kHz, MHz, cm, cm2, cm3, mm, mm2, mm3, um, um2, um3

Exported members: mV, mA, uA, nA, pA, pF, uF, nF, nS, uS, ms, us, Hz, kHz, MHz, cm, cm2, cm3, mm, mm2, mm3, um, um2, um3

unitsafefunctions module

Unit-aware replacements for numpy functions.

Exported members: log(), log10(), exp(), sin(), cos(), tan(), arcsin(), arccos(), arctan(), sinh(), cosh(), tanh(), arcsinh(), arccosh(), arctanh(), diagonal(), ravel(), trace(), dot(), where(), ones_like(), zeros_like()


arccos(x[, out]) Trigonometric inverse cosine, element-wise.
arccosh(x[, out]) Inverse hyperbolic cosine, element-wise.
arcsin(x[, out]) Inverse sine, element-wise.
arcsinh(x[, out]) Inverse hyperbolic sine element-wise.
arctan(x[, out]) Trigonometric inverse tangent, element-wise.
arctanh(x[, out]) Inverse hyperbolic tangent element-wise.
cos(x[, out]) Cosine element-wise.
cosh(x[, out]) Hyperbolic cosine, element-wise.
diagonal(x, *args, **kwds) Return specified diagonals.
dot(a, b[, out]) Dot product of two arrays.
exp(x[, out]) Calculate the exponential of all elements in the input array.
log(x[, out]) Natural logarithm, element-wise.
ravel(x, *args, **kwds) Return a flattened array.
setup() Setup function for doctests (used by nosetest).
sin(x[, out]) Trigonometric sine, element-wise.
sinh(x[, out]) Hyperbolic sine, element-wise.
tan(x[, out]) Compute tangent element-wise.
tanh(x[, out]) Compute hyperbolic tangent element-wise.
trace(x, *args, **kwds) Return the sum along diagonals of the array.
where(condition, [x, y]) Return elements, either from x or y, depending on condition.
wrap_function_to_method(func) Wraps a function so that it calls the corresponding method on the Quantities object (if called with a Quantities object as the first argument).