Skip to content

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

@vegardkv

Description

@vegardkv

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions