Skip to content

Commit

Permalink
Merge pull request #23761 from charris/backport-23680
Browse files Browse the repository at this point in the history
BUG: Fix masked array ravel order for A (and somewhat K)
  • Loading branch information
charris committed May 14, 2023
2 parents 1c3b98d + afa144d commit 553bb3f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4656,7 +4656,7 @@ def ravel(self, order='C'):
# 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:
Expand Down
2 changes: 2 additions & 0 deletions numpy/ma/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3441,6 +3441,8 @@ def test_ravel_order(self, order, data_order):
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
Expand Down

0 comments on commit 553bb3f

Please sign in to comment.