summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorRuth Comer <ruth.comer@metoffice.gov.uk>2022-07-16 14:40:27 +0100
committerRuth Comer <ruth.comer@metoffice.gov.uk>2022-07-16 15:00:11 +0100
commite2efced9bdfc773f5aca2487f12ab1cb2bd11833 (patch)
treedde310341fd3b57075bce6bd71eca6f8b67677fb /numpy
parentbdec32181605c8179fd79624d14c1cf019de75af (diff)
downloadnumpy-e2efced9bdfc773f5aca2487f12ab1cb2bd11833.tar.gz
TST: add a test for ma.minimum.reduce with axis keyword
Adapted from the problem reported at https://github.com/numpy/numpy/pull/21977#issuecomment-1186082534
Diffstat (limited to 'numpy')
-rw-r--r--numpy/ma/tests/test_core.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index 5b779edcb..c2ba6fd77 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -1235,6 +1235,18 @@ class TestMaskedArrayArithmetic:
b = np.maximum.reduce(a)
assert_equal(b, 3)
+ def test_minmax_reduce_axis(self):
+ # Test np.min/maximum.reduce along an axis for 2D array
+ import numpy as np
+ data = [[0, 1, 2, 3, 4, 9], [5, 5, 0, 9, 3, 3]]
+ mask = [[0, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0]]
+ a = array(data, mask=mask)
+
+ expected = array([0, 3], mask=False)
+ result = np.minimum.reduce(a, axis=1)
+
+ assert_array_equal(result, expected)
+
def test_minmax_funcs_with_output(self):
# Tests the min/max functions with explicit outputs
mask = np.random.rand(12).round()