Fixed iris.util.array_equal to avoid issues with fully masked arrays#905
Merged
pelson merged 2 commits intoSciTools:masterfrom Jan 15, 2014
Merged
Fixed iris.util.array_equal to avoid issues with fully masked arrays#905pelson merged 2 commits intoSciTools:masterfrom
pelson merged 2 commits intoSciTools:masterfrom
Conversation
Member
There was a problem hiding this comment.
Do we not need to give this a specific name? (Update: No, it appears not).
Member
There was a problem hiding this comment.
Given the reason this function exists at all, I'd be more comfortable if there was a test checking the string equality (with strings of different lengths).
Member
|
Other than that, the implementation certainly is much neater. 👍 |
Member
Author
|
I've added some more tests @pelson. |
pelson
added a commit
that referenced
this pull request
Jan 15, 2014
Fixed iris.util.array_equal to avoid issues with fully masked arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following fails on upstream/master:
producing
ValueError: This operation cannot be performed as there are differing coordinates (longitude) remaining which cannot be ignored.I tracked this down to the fact the longitude coordinate is fully masked (I know masked coords are not supported in Iris, but that can wait for another day). The problem stems from:
This PR fixes the problem by altering
iris.util.array_equalso it ignores any mask if present. This matches the behaviour ofnumpy.array_equalas stated in the existingiris.util.array_equaldocstring. You could argue that we should modify the function to handle masked_arrays properly (that is open to various interpretations), but the chosen approach fixes the problem, is simpler, and reflects numpy behaviour.Note that the change also means that
iris.util.array_equalnow matchesnumpy.array_equalin other ways too such as handling other types vianp.asarray().