summaryrefslogtreecommitdiff
path: root/numpy/ma/core.py
diff options
context:
space:
mode:
authoryuki <drsuaimqjgar@gmail.com>2023-03-22 01:23:16 +0000
committeryuki <drsuaimqjgar@gmail.com>2023-03-22 01:23:16 +0000
commit03a87196e9f51d87b7c28d726b795b8fd0547a98 (patch)
tree0619f7a9fdfc76824d093d6cc32b8cbef4660fc3 /numpy/ma/core.py
parent604ce598760d632b5aa286b1cfcac9b7df6be090 (diff)
downloadnumpy-03a87196e9f51d87b7c28d726b795b8fd0547a98.tar.gz
ENH: revert changes of `mask_rowcols`
Diffstat (limited to 'numpy/ma/core.py')
-rw-r--r--numpy/ma/core.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index e6d696288..95692bc52 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -7842,16 +7842,20 @@ def mask_rowcols(a, axis=None):
fill_value=1)
"""
+ a = array(a, subok=False)
if a.ndim != 2:
raise NotImplementedError("mask_rowcols works for 2D arrays only.")
-
- if axis is None:
- return _mask_propagate(a, axis=(0, 1))
- elif axis == 0:
- return _mask_propagate(a, axis=1)
- else:
- return _mask_propagate(a, axis=0)
-
+ m = getmask(a)
+ # Nothing is masked: return a
+ if m is nomask or not m.any():
+ return a
+ maskedval = m.nonzero()
+ a._mask = a._mask.copy()
+ if not axis:
+ a[np.unique(maskedval[0])] = masked
+ if axis in [None, 1, -1]:
+ a[:, np.unique(maskedval[1])] = masked
+ return a
# Include masked dot here to avoid import problems in getting it from