saiunit.add_standard_unit

saiunit.add_standard_unit#

saiunit.add_standard_unit(u)[source]#

Register a unit as a standard unit for display purposes.

Once registered, this unit will be used when formatting quantities whose dimensions, scale, base, and factor match. If multiple units are registered for the same key, the preferred alias is selected automatically. Keys with two or more distinct display names are flagged as ambiguous and will not be auto-substituted during unit composition.

Parameters:

u (saiunit.Unit) – The unit to register. Its base, scale, and factor must all be plain Python int or float values (not JAX tracers) for registration to take effect.

Examples

>>> import saiunit as u
>>> my_unit = u.Unit(
...     dim=u.joule.dim,
...     name='my_energy',
...     dispname='myE',
...     is_fullname=True,
... )
>>> u.add_standard_unit(my_unit)