如何在 Pint 中测试单位等效性?例如,nM
等价于nmol/L
和L
等价于dm^3
,但根据品脱,它们不相等。我不想要 Pint 通过该is_compatible_with
方法提供的兼容性。例如,s
与 兼容ms
,但它们不等价。
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