How do I test for unit equivalence in Pint? For example, nM
is equivalent to nmol/L
and L
is equivalent to dm^3
, but they are not equal according to Pint. I don't want compatibility, which Pint provides via the is_compatible_with
method. For example, s
is compatible with ms
, but they are not equivalent.
import pint
ureg = pint.UnitRegistry()
nM = ureg.Unit('nM')
nmol_L = ureg.Unit('nmol/L')
m = ureg.Unit('m')
ft = ureg.Unit('ft')
nM == nmol_L # False
m == ft # False
nM.is_compatible_with(nmol_L) # True
m.is_compatible_with(ft) # True
# What operation does this?
# nM equivalent to nmol # Should be True
# m equivalent to ft # Should be False