diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-06-27 00:32:17 +0100 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-06-27 00:32:17 +0100 |
commit | 715daa97ad716da52ada07eb10cc37b314428311 (patch) | |
tree | 58133ecf1bf5b31323b2f7dde07803d879df5b5d | |
parent | c11ce16f7c025fa144ccb5b9d7351bba9d3b885d (diff) | |
download | numpy-715daa97ad716da52ada07eb10cc37b314428311.tar.gz |
BUG: Fix gh-8069
Fill values were not correctly calculated for subdtypes, instead returning `None`
-rw-r--r-- | numpy/ma/core.py | 7 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index e091baa22..d0b18fb3a 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -277,7 +277,12 @@ def _recursive_extremum_fill_value(ndtype, extremum): fval = _recursive_extremum_fill_value(ndtype[name], extremum) deflist.append(fval) return tuple(deflist) - return extremum[ndtype] + elif ndtype.subdtype: + subtype, shape = ndtype.subdtype + subval = _recursive_extremum_fill_value(subtype, extremum) + return np.full(shape, subval) + else: + return extremum[ndtype] def _extremum_fill_value(obj, extremum, extremum_name): diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index bba8f2cb7..26099455d 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -1879,6 +1879,15 @@ class TestFillingValues(TestCase): assert_equal(test[1][1], maximum_fill_value(a['B']['BB'])) assert_equal(test[1], maximum_fill_value(a['B'])) + def test_extremum_fill_value_subdtype(self): + a = array(([2, 3, 4],), dtype=[('value', np.int8, 3)]) + + test = minimum_fill_value(a) + assert_equal(test[0], np.full(3, minimum_fill_value(a['value']))) + + test = maximum_fill_value(a) + assert_equal(test[0], np.full(3, maximum_fill_value(a['value']))) + def test_fillvalue_individual_fields(self): # Test setting fill_value on individual fields ndtype = [('a', int), ('b', int)] |