With pint, how can I filter the units in pint.UnitRegistry
by dimensionality? For example, how could I get all units of mass type or of volume type?
Get all units of a particular dimensionality with pint
Asked Answered
I believe you're looking for the get_compatible_units
method.
>>> ureg = pint.UnitRegistry()
>>> ureg.get_compatible_units('[mass]')
frozenset({<Unit('electron_mass')>,
<Unit('atomic_mass_unit')>,
# .... many more
<Unit('UK_ton')>,
<Unit('long_ton')>})
© 2022 - 2024 — McMap. All rights reserved.