diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2023-05-14 14:26:57 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-14 14:26:57 -0600 |
commit | 553bb3fe58e606ee257765cad526be479178f643 (patch) | |
tree | b0d6d72bfa27dfbff02306b1622ae70d55dd788f | |
parent | 1c3b98ddc1fadfc8bf7cac9ba5c837c2d9c06053 (diff) | |
parent | afa144d4a57e1da99b75327722d6605bf35a4a85 (diff) | |
download | numpy-maintenance/1.24.x.tar.gz |
Merge pull request #23761 from charris/backport-23680maintenance/1.24.x
BUG: Fix masked array ravel order for A (and somewhat K)
-rw-r--r-- | numpy/ma/core.py | 2 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index acf1a0444..5fb16d0cb 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -4656,7 +4656,7 @@ class MaskedArray(ndarray): # TODO: We don't actually support K, so use A instead. We could # try to guess this correct by sorting strides or deprecate. if order in "kKaA": - order = "C" if self._data.flags.fnc else "F" + order = "F" if self._data.flags.fnc else "C" r = ndarray.ravel(self._data, order=order).view(type(self)) r._update_from(self) if self._mask is not nomask: diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 6c03e0ba2..722b3ded4 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -3441,6 +3441,8 @@ class TestMaskedArrayMethods: raveled = x.ravel(order) assert (raveled.filled(0) == 0).all() + # NOTE: Can be wrong if arr order is neither C nor F and `order="K"` + assert_array_equal(arr.ravel(order), x.ravel(order)._data) def test_reshape(self): # Tests reshape |