diff options
| author | Sebastian Berg <sebastianb@nvidia.com> | 2023-04-28 14:41:00 +0200 |
|---|---|---|
| committer | Sebastian Berg <sebastianb@nvidia.com> | 2023-04-28 14:41:00 +0200 |
| commit | e8920038ade22a8966fb977e77aa00a82142901b (patch) | |
| tree | 32cf12dcad89860a2432364b8aadafc34ed4c02b /numpy | |
| parent | f983afd70046e807dd61962800ce147f42ccc457 (diff) | |
| download | numpy-e8920038ade22a8966fb977e77aa00a82142901b.tar.gz | |
BUG: Fix masked array ravel order for A (and somewhat K)
Swaps the order to the correct thing and thus
closes gh-23651
Diffstat (limited to 'numpy')
| -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 0cf748dfd..2fe326885 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -4668,7 +4668,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 9a4b74997..55b15fc34 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -3444,6 +3444,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 |
