From 44c8da9f2caa5e09c78204e487cf74fe53c6d0d4 Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Mon, 25 Jul 2022 14:00:02 -1000 Subject: Make mask_invalid consistent with mask_where when copy is set to False. Add test for type erroring. --- numpy/ma/core.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'numpy/ma/core.py') diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 93eb74be3..405937046 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -2356,20 +2356,11 @@ def masked_invalid(a, copy=True): fill_value=1e+20) """ - a = np.array(a, copy=copy, subok=True) - mask = getattr(a, '_mask', None) - if mask is not None: - condition = ~(np.isfinite(getdata(a))) - if mask is not nomask: - condition |= mask - cls = type(a) - else: - condition = ~(np.isfinite(a)) - cls = MaskedArray - result = a.view(cls) - result._mask = condition - return result + try: + return masked_where(~(np.isfinite(getdata(a))), a, copy=copy) + except TypeError: + raise ############################################################################### # Printing options # -- cgit v1.2.1 From 4213779a4a1108f5908a51dd96ed468057f2c1f2 Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Wed, 7 Sep 2022 08:22:36 -1000 Subject: Remove try statement. Add test. --- numpy/ma/core.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'numpy/ma/core.py') diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 405937046..812c48ced 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -2357,10 +2357,7 @@ def masked_invalid(a, copy=True): """ - try: - return masked_where(~(np.isfinite(getdata(a))), a, copy=copy) - except TypeError: - raise + return masked_where(~(np.isfinite(getdata(a))), a, copy=copy) ############################################################################### # Printing options # -- cgit v1.2.1