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/tests/test_core.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'numpy/ma/tests') diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index b056d5169..5a6d642b4 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -4496,6 +4496,13 @@ class TestMaskedArrayFunctions: assert_equal(ma, expected) assert_equal(ma.mask, expected.mask) + def test_masked_invalid_error(self): + a = np.arange(5, dtype=object) + a[3] = np.PINF + a[2] = np.NaN + with pytest.raises(TypeError, match="not supported for the input types"): + np.ma.masked_invalid(a) + def test_choose(self): # Test choose choices = [[0, 1, 2, 3], [10, 11, 12, 13], -- cgit v1.2.1 From 2d73e10f7a0e0d85247cd2f9c20c6a0b462dc77e Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Mon, 25 Jul 2022 16:23:45 -1000 Subject: Fix lint. --- numpy/ma/tests/test_core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'numpy/ma/tests') diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 5a6d642b4..3c233b9cd 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -4500,7 +4500,8 @@ class TestMaskedArrayFunctions: a = np.arange(5, dtype=object) a[3] = np.PINF a[2] = np.NaN - with pytest.raises(TypeError, match="not supported for the input types"): + with pytest.raises(TypeError, + match="not supported for the input types"): np.ma.masked_invalid(a) def test_choose(self): -- 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/tests/test_core.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'numpy/ma/tests') diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 3c233b9cd..8304a2d24 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -5317,6 +5317,10 @@ def test_masked_array_no_copy(): a = np.ma.array([1, 2, 3, 4], mask=[1, 0, 0, 0]) _ = np.ma.masked_where(a == 3, a, copy=False) assert_array_equal(a.mask, [True, False, True, False]) + # check masked array with masked_invalid is updated in place + a = np.ma.array([np.inf, 1, 2, 3, 4]) + _ = np.ma.masked_invalid(a, copy=False) + assert_array_equal(a.mask, [True, False, False, False, False]) def test_append_masked_array(): a = np.ma.masked_equal([1,2,3], value=2) -- cgit v1.2.1