summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2023-04-21 18:18:38 -0400
committerGitHub <noreply@github.com>2023-04-21 18:18:38 -0400
commit41b0722d1eaf982adfc2ebc2a4a8ea1f6dfc65d8 (patch)
tree8614718d5a25f560ad859d3444ed9d7219f17b1e
parent5fd25ab98c5834c6806564dfb2d937bd48933940 (diff)
parent77a5aab54e10e063773e9aaf0e3730bf0cfefa9b (diff)
downloadnumpy-41b0722d1eaf982adfc2ebc2a4a8ea1f6dfc65d8.tar.gz
Merge pull request #23626 from seberg/issue-22912
BUG: Fix masked array raveling when `order="A"` or `order="K"`
-rw-r--r--numpy/ma/tests/test_core.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index 1f8101559..9a4b74997 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -3429,6 +3429,22 @@ class TestMaskedArrayMethods:
assert_equal(a.ravel(order='C'), [1, 2, 3, 4])
assert_equal(a.ravel(order='F'), [1, 3, 2, 4])
+ @pytest.mark.parametrize("order", "AKCF")
+ @pytest.mark.parametrize("data_order", "CF")
+ def test_ravel_order(self, order, data_order):
+ # Ravelling must ravel mask and data in the same order always to avoid
+ # misaligning the two in the ravel result.
+ arr = np.ones((5, 10), order=data_order)
+ arr[0, :] = 0
+ mask = np.ones((10, 5), dtype=bool, order=data_order).T
+ mask[0, :] = False
+ x = array(arr, mask=mask)
+ assert x._data.flags.fnc != x._mask.flags.fnc
+ assert (x.filled(0) == 0).all()
+ raveled = x.ravel(order)
+ assert (raveled.filled(0) == 0).all()
+
+
def test_reshape(self):
# Tests reshape
x = arange(4)