Fixed iris.util.array_equal to avoid issues with fully masked arrays #905
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().