diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-02-12 08:10:14 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-02-12 11:21:51 -0700 |
commit | 8552cd5fcbf52dee79bdade97ca36c18599e64b4 (patch) | |
tree | 6ab4748c181695e15fbf30bda24629a404784602 /numpy/lib/tests/test_regression.py | |
parent | 0a87823d048fca997684e86718be0d46459ad4fd (diff) | |
download | numpy-8552cd5fcbf52dee79bdade97ca36c18599e64b4.tar.gz |
BUG: Make nansum work with booleans.
This broke when function_base._nannop tried to fill a boolean array with
integer zeros, raising a 'safe_casting' error. It looks like nanargmax and
nanargmin would also break, and were probably incorrect for booleans in any
case. The fix is not to use fill values for boolean and integer dtypes.
Previously that was only done for the integer dtypes.
Diffstat (limited to 'numpy/lib/tests/test_regression.py')
-rw-r--r-- | numpy/lib/tests/test_regression.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_regression.py b/numpy/lib/tests/test_regression.py index 71400d112..270da73e3 100644 --- a/numpy/lib/tests/test_regression.py +++ b/numpy/lib/tests/test_regression.py @@ -218,5 +218,14 @@ class TestRegression(TestCase): data = [((((0,1), (2,3), (4,5)), ((6,7), (8,9), (10,11))),)] assert_equal(x, np.array(data, dtype=dt)) + def test_nansum_with_boolean(self): + # gh-2978 + a = np.zeros(2, dtype=np.bool) + try: + np.nansum(a) + except: + raise AssertionError() + + if __name__ == "__main__": run_module_suite() |