-
Notifications
You must be signed in to change notification settings - Fork 296
Fix equality #3536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix equality #3536
Conversation
After having a bit more of a look at |
I think you've mis-diagnosed what was wrong here. The errors with set creation occur because the elements of And the same thing needs fixing for cell measures here. If you fix those, I think the set approach will work. I really like this approach (if you can make it work), because it provides all the needed logic based only+entirely on equality testing, which being a standard approach is very easy to understand. |
WARNING |
@pp-mo For consistency, I have made the same change to |
cube1.add_cell_method(cmth2) | ||
cube2.add_cell_method(cmth2) | ||
cube2.add_cell_method(cmth1) | ||
self.assertFalse(cube1 == cube2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a successful comparison with cell-methods here, or is that covered somewhere else ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is capturing the behaviour mentioned in the comments on #3530. Adding cell_methods in different orders should cause equality to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misunderstanding I think !
What I meant to say was : do we need another testcase showing that equality testing succeeds, when the cubes have cell methods, but they do match.
( Unless that is clearly covered somewhere else ?? )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, yeah, that sounds appropriate.
Looking very close, I think I'd still push for a test of successful cell-method comparisons, OWOK ! 😁 |
Good stuff 👍 |
Closes #3529. |
This pull request currently shows an approach to solving #3529 which, while failed, I think is still instructive.
I tried comparing
_ancillary_variables_and_dims
and_cell_measures_and_dims
in a way which would ignore their order as lists. This first attempt involved simply turning these lists into sets. This failed because the objects inside the lists are not viable elements of a set.One idea I am coming around to, if such a comparison is deemed necessary, is to use the code in this function:
iris/lib/iris/analysis/__init__.py
Line 189 in a054241
coord_comparison
and something likeancil_comparison
wrap this generic function. I'm leaning towards this idea since it seems as thoughcoord_comparison
is designed to be more efficient than a more naive, brute force approach. If we needed to compare many ancillary variables (which seems like a thing we would probably want to do) it seems likely we would end up writing something similar to what already exists in this code anyway.