Use np.ma.is_masked() instead of isinstance(MaskedArray) in tests#2477
Merged
marqh merged 3 commits intoSciTools:masterfrom Apr 6, 2017
Merged
Use np.ma.is_masked() instead of isinstance(MaskedArray) in tests#2477marqh merged 3 commits intoSciTools:masterfrom
marqh merged 3 commits intoSciTools:masterfrom
Conversation
…st failures are incorrect
Merged
75b3dee to
de8e390
Compare
de8e390 to
64f195b
Compare
Member
|
thank you @djkirkham this is a better test pattern, I think, asking whether the data is masked, rather than checking if it's type is 'maskedarray' the only changes here are test results which were not masked, but were of masked array type, so this is a testing pattern change only |
bjlittle
reviewed
Apr 10, 2017
| self.assertEqual(stats.get('shape', []), list(data.shape)) | ||
| self.assertEqual(stats.get('masked', False), | ||
| isinstance(data, ma.MaskedArray)) | ||
| np.ma.is_masked(data)) |
Member
There was a problem hiding this comment.
@djkirkham We have a soft coding standard where we use ma instead of np.ma, see here.
If it's not too much trouble, could you adopt this please, thanks.
bjlittle
reviewed
Apr 10, 2017
| ('min', np.float_(data.min())), | ||
| ('max', np.float_(data.max())), | ||
| ('shape', data.shape), | ||
| ('masked', np.ma.is_masked(data)), |
Member
There was a problem hiding this comment.
@djkirkham Here is well ... np.ma.is_masked(data) -> ma.is_masked(data)
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.
Due to some changes in Numpy 1.12, some aggregator functions in np.ma return a MaskedArray instance with no mask rather than an ndarray. This causes some of our tests to fail which do an instance check for a MaskedArray.
I've modified the checking code to use np.ma.is_masked(), but this causes other tests to fail where the array being checked has always been a MaskedArray instance with no mask (thus, the reference file claims it is masked when it isn't). Commit dfa75a3 demonstrates this - see the Travis test failures. Note that because some tests contain multiple checks, not all of the checks which would fail are listed in the output.