8000 TST: Fix some MA tests to avoid looking at the .data attribute by ahaldane · Pull Request #7351 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

TST: Fix some MA tests to avoid looking at the .data attribute #7351

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

Merged
merged 1 commit into from
Feb 26, 2016

Conversation

ahaldane
Copy link
Member

The MaskedArray.data attribute is unreliable for tests because it can contain arbitrary junk data at masked positions. Instead, all MaskedArray tests should look at marr.filled(0) to check if we got the expected result.

This PR is split off from #5706. These unit tests were failing after further changes there.

In fact, it was very confusing because these unit tests will fail but only depending on the order in which tests run: Some unit tests write to the data value in the masked singleton, and then other unit tests assign to elements of a masked array using the masked singleton, which means that their data values get set to whatever the masked singleton had. These later unit tests then check for particular values in the .data attribute, but that will change depeding on which unit tests modified the masked singleton previously. My changes in #5706 were simply causing the unit tests to run in a different order, causing failures.

I spent a long time looking into whether it was possible to prevent writing to the masked singleton, but concluded it is not.

The MaskedArray.data attribute is unreliable for tests because it can
contain arbitraty junk data at masked positions. Instead, all
MaskedArray tests should look at marr.filled(0) to check if we got the
same result.
@mhvk
Copy link
Contributor
mhvk commented Feb 26, 2016

These changes all look good to me.

charris added a commit that referenced this pull request Feb 26, 2016
TST: Fix some MA tests to avoid looking at the .data attribute
@charris charris merged commit fe25160 into numpy:master Feb 26, 2016
@charris
Copy link
Member
charris commented Feb 26, 2016

Thanks Allan.

@ahaldane ahaldane deleted the ma_fix_1_datatest branch January 17, 2018 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0