Configurable numeric equality #5987
trexfeathers
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
Ping @larsbarring |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
From offline discussion between @trexfeathers, @bjlittle, @pp-mo
Just as with metadata equality, Iris users have diverse needs when it comes to numeric equality1:
np.allclose()
NaN
be handled? ExampleThese considerations touch all corners of Iris: arithmetic, merging (and therefore loading), constraints (I remember #4744), and many more. Not only is this about whether numbers are equal, but also performance (e.g. #5926).
Problems
Cube
be subtracted from thatCube
? Are theseCoord
s duplicates? Etcetera)Suggestion
Given different user needs, it would probably be unwise to enforce a consistent approach everywhere. User configuration seems the better approach, but since this is often about Iris internals I personally favour a global config with a context manager. We have established a precedent with Leniency, although this would not look exactly the same since it seems overly complex to offer the config as a parameter for every affected operation.
Possible settings
Allow the user to set any of the kwargs in
np.allclose()
. Perhaps if nothing is set then exact equality is used - possibly using a fast hashing algorithm.Footnotes
I am mostly referring to arrays, but this may apply to single numbers such as those in a
CoordSystem
subclass. ↩Beta Was this translation helpful? Give feedback.
All reactions