Skip to content

Commit

Permalink
Merge pull request #23635 from charris/backport-23626
Browse files Browse the repository at this point in the history
BUG: Fix masked array raveling when `order="A"` or `order="K"`
  • Loading branch information
charris committed Apr 22, 2023
2 parents 58025a4 + 7576313 commit 9e20855
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions numpy/ma/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3426,6 +3426,22 @@ def test_ravel(self):
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)
Expand Down

0 comments on commit 9e20855

Please sign in to comment.