hgrecco / pint

Operate and manipulate physical quantities in Python
http://pint.readthedocs.org/
Other
2.37k stars 466 forks source link

Measurement equality operator inconsistent #763

Open deniz195 opened 5 years ago

deniz195 commented 5 years ago

The following example shows that the equality operator between two Measurement objects is surprizing (in a bad way):

import pint
ureg = pint.UnitRegistry()

m1 = ureg('42 count').plus_minus(7)
m2 = ureg('42 count').plus_minus(7)
assert(m1 == m2) # fails!

One can debate the semantics of equality between two values with an errorbar. Still, in this case the objects m1 and m2 are made in the same way from the same registry, and so I would expect that they compare equal.

Currently this is the case for Quantities:

q1 = ureg('42 count')
q2 = ureg('42 count')
assert(q1 == q2) # ok!

Several possibilities:

Thoughts?

hgrecco commented 5 years ago

I am not really sure about this but what I can say is that the support for this in pint is stalled

My suggestion here is: 1.- Just like we did for pandas, lets create a pint-measurements package 2.- Remove all measurements related things from pint and use pint-measurements (when installed) 3.- Let it evolve independently and with a better defined API and rationale.

deniz195 commented 5 years ago

Hi, I looked a bit into this. I think removing the Measurement class and going back to using Quantity class with a ufloat magnitude (for the people who want that) should work fine.

Do you want me to prepare a pull request for that? Or do you want to wait for removing this?