- qunits. Unit ( scale , exp_map , dimension , context )[source]
-
A physical unit. Units are usually taken from the registry
uand combined with*,/and**(integer powers). Multiplying a number or an array with a unit creates aQuantity.There is exactly one unit per exponent map, so units can be compared with
is.Defines a new unit. If the unit is already defined with the same scale, dimension and context, the existing unit is returned.
- Parameters:
- Attributes:
-
- contextContext
The
Contextof the unit. Only quantities with the same dimension and context can be added, subtracted or converted into each other.- dtype[Dimension]
The
Dimensionof the unit, same asdimension.- dimtype[Dimension]
The
Dimensionof the unit, same asdimension.- dimensiontype[Dimension]
The
Dimensionof the unit.- exp_mapExpMap
The
ExpMapof the unit, e.g.frozenset({("m", 1), ("s", -1)})for m/s. It identifies the unit and is how the unit is printed.- scalefloat
The scale factor of the unit relative to the SI unit of its dimension, e.g. 1000.0 for km.
- Raises:
-
- ValueError
If a unit with the same
exp_mapbut another scale, dimension or context is defined.