summaryrefslogtreecommitdiff
path: root/numpy/ma/core.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastianb@nvidia.com>2022-12-19 20:20:09 +0100
committerSebastian Berg <sebastianb@nvidia.com>2022-12-19 20:22:20 +0100
commit45cb03723b863b0814092631fe9cf17df67add4e (patch)
tree1a4642f29176e5a9495a5be334b62f6c7e1106e5 /numpy/ma/core.py
parentbf35f9bafc71283afd8538fae58e02177f4c126a (diff)
downloadnumpy-45cb03723b863b0814092631fe9cf17df67add4e.tar.gz
BUG: Do not use getdata() in np.ma.masked_invalid
This is the minimal solution to fix gh-22826 with as little change as possible. We should fix `getdata()` but I don't want to do that in a bug-fix release really. IMO the alternative is to revert gh-22046 which would also revert the behavior noticed in gh-22720 (which seems less harmful though). Closes gh-22826
Diffstat (limited to 'numpy/ma/core.py')
-rw-r--r--numpy/ma/core.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 59ba3a593..0038d2d6e 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -2310,7 +2310,7 @@ def masked_values(x, value, rtol=1e-5, atol=1e-8, copy=True, shrink=True):
mask=False,
fill_value=2.1)
- Unlike `masked_equal`, `masked_values` can perform approximate equalities.
+ Unlike `masked_equal`, `masked_values` can perform approximate equalities.
>>> ma.masked_values(x, 2.1, atol=1e-1)
masked_array(data=[1.0, 1.1, --, 1.1, 3.0],
@@ -2356,8 +2356,8 @@ def masked_invalid(a, copy=True):
fill_value=1e+20)
"""
-
- return masked_where(~(np.isfinite(getdata(a))), a, copy=copy)
+ a = np.array(a, copy=False, subok=True)
+ return masked_where(~(np.isfinite(a)), a, copy=copy)
###############################################################################
# Printing options #
@@ -2869,7 +2869,7 @@ class MaskedArray(ndarray):
else:
# Case 2. : With a mask in input.
# If mask is boolean, create an array of True or False
-
+
# if users pass `mask=None` be forgiving here and cast it False
# for speed; although the default is `mask=nomask` and can differ.
if mask is None:
@@ -2922,7 +2922,7 @@ class MaskedArray(ndarray):
else:
_data._mask = np.logical_or(mask, _data._mask)
_data._sharedmask = False
-
+
# Update fill_value.
if fill_value is None:
fill_value = getattr(data, '_fill_value', None)