Description
Description
Comparing a quantity with units to dimensionless zero always works, presumably because for a given comparison it is reasonable to assume that dimensionless zero is the same as zero times a unit. However, this results in an amusing edge case when working with two units where the zero point does not coincide. For example, you can't normally compare degrees Celsius and Kelvin without the temperature()
equivalency:
>>> -1*u.Celsius < 1*u.Kelvin
...
UnitConversionError: 'K' (temperature) and 'deg_C' (temperature) are not convertible
...
>>> -1*u.Celsius < (1*u.Kelvin).to(u.Celsius, equivalencies=u.temperature())
False
But, if you throw dimensionless zero into the mix, you seemingly can compare them without the equivalency (through transitivity) and then obtain the wrong answer.
>>> -1*u.Celsius < 0
True
>>> 1*u.Kelvin > 0
True
>>> -1*u.Celsius < 0 < 1*u.Kelvin
True
Expected behavior
Something not amusing, but this example is rather contrived
How to Reproduce
See description
Versions
Windows-10-10.0.22621-SP0
Python 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:00:38) [MSC v.1934 64 bit (AMD64)]
astropy 5.2.2
Numpy 1.24.3
pyerfa 2.0.0.3
Scipy 1.10.1
Matplotlib 3.7.1