Skip to content
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

BUG: Changed behavior for masked_invalid in 1.24 for Fortran ordered arrays #22912

Closed
vegardkv opened this issue Jan 2, 2023 · 1 comment · Fixed by #23626
Closed

BUG: Changed behavior for masked_invalid in 1.24 for Fortran ordered arrays #22912

vegardkv opened this issue Jan 2, 2023 · 1 comment · Fixed by #23626

Comments

@vegardkv
Copy link

vegardkv commented Jan 2, 2023

Describe the issue:

The behavior of ma.masked_invalid seems to have changed from 1.23 to 1.24 in a breaking way for Fortran ordered arrays. I assume it could be related to #22046. To me, this seems like a bug, although I am not that familiar with the background for this change.

Reproduce the code example:

import numpy as np
a = np.array([np.nan, np.nan, np.nan, 1, 1, 1]).reshape((3, 2), order="F")
a_masked = np.ma.masked_invalid(a)
print(np.isfortran(a_masked.data), np.isfortran(a_masked.mask))
# Expected output: True True
# Output in 1.24: True False
# Output in 1.23: True True

# A specific implication is that the following produces the wrong result:
print(np.isnan(a.ravel(order="K").data).any())  # Yields True for 1.24, but should be False

Error message:

No response

Runtime information:

import sys, numpy; print(numpy.version); print(sys.version)
1.24.1
3.8.15 | packaged by conda-forge | (default, Nov 22 2022, 08:42:03) [MSC v.1929 64 bit (AMD64)]

print(numpy.show_runtime())
WARNING: threadpoolctl not found in system! Install it by pip install threadpoolctl. Once installed, try np.show_runtime again for more detailed build information
[{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL'],
'not_found': []}}]
None

Context for the issue:

No response

@seberg
Copy link
Member

seberg commented Jan 2, 2023

Hmmmpf, if this is a bug, it is one that always existed in np.ma.masked_where.

I rather think it is a bug in MaskedArray.ravel() though, although I don't mind if we change np.ma.masked_where to try to retain order.

@seberg seberg added the component: numpy.ma masked arrays label Jan 2, 2023
@charris charris added this to the 1.24.2 release milestone Jan 2, 2023
@charris charris modified the milestones: 1.24.2 release, 1.24.3 release Feb 3, 2023
seberg added a commit to seberg/numpy that referenced this issue Apr 21, 2023
This transitively fixes numpygh-22912.  I had alooked a bit into whether
it is worthwhile to preserve the mask order, but TBH, we seem to not
do so in so many places, that I don't think it really is worthwhile.

Applying `order="K"` or `order="A"` to the data and mask separately
is an big bug though.

Closes numpygh-22912
charris pushed a commit to charris/numpy that referenced this issue Apr 21, 2023
This transitively fixes numpygh-22912.  I had alooked a bit into whether
it is worthwhile to preserve the mask order, but TBH, we seem to not
do so in so many places, that I don't think it really is worthwhile.

Applying `order="K"` or `order="A"` to the data and mask separately
is an big bug though.

Closes numpygh-22912
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants