Logo

A performant, verbose and generic physical unit system.

Static Badge Static Badge

© 2026 Patrick Müller. All rights reserved.

qunits.Unit  (  scale = 1.0 dimension = "Dimensionless" context = "" symbol = None prefix_exp = None  )[source]

The base class for units. Creating a new unit with the same dimension and scale of an existing unit will return the cached instance. The symbol and prefix_exp attributes are only used for string representation and are set to the first created unit.

Parameters:
scalescalar

The scale by which the unit is multiplied (e.g., 1.0 for Tesla, 1e-4 for Gauss).

dimensiontype[qunits.dimension.Dimension]

The dimension of the unit (e.g., Length, Mass, Time).

contextstr

The context of the unit (e.g., "", "angle", "solid-angle").

symbolstr | None

The symbol of the unit (e.g., "m" for meter, "s" for second).

prefix_expint | None

The exponent of the prefix (e.g., -3 for milli, 3 for kilo).