diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-02-24 00:21:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-24 00:21:02 +0000 |
commit | 5f5ccecbfc116284ed8c8d53cd8b203ceef5f7c7 (patch) | |
tree | f099a39775f79303149ac68a231741f4fa2884df /numpy/lib/tests | |
parent | 97b1dfc2a7f48833084adcd234503b979c9e7fd7 (diff) | |
parent | 89944e80e6fc9bc47d1666b9a7572827138f90e3 (diff) | |
download | numpy-5f5ccecbfc116284ed8c8d53cd8b203ceef5f7c7.tar.gz |
Merge pull request #8646 from joshloyal/enh-inplace-nan_to_num
ENH: Allow for an in-place nan_to_num conversion
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_type_check.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py index 4523e3f24..473b558be 100644 --- a/numpy/lib/tests/test_type_check.py +++ b/numpy/lib/tests/test_type_check.py @@ -320,6 +320,16 @@ class TestNanToNum(TestCase): assert_(vals[1] == 0) assert_all(vals[2] > 1e10) and assert_all(np.isfinite(vals[2])) + # perform the same test but in-place + with np.errstate(divide='ignore', invalid='ignore'): + vals = np.array((-1., 0, 1))/0. + result = nan_to_num(vals, copy=False) + + assert_(result is vals) + assert_all(vals[0] < -1e10) and assert_all(np.isfinite(vals[0])) + assert_(vals[1] == 0) + assert_all(vals[2] > 1e10) and assert_all(np.isfinite(vals[2])) + def test_integer(self): vals = nan_to_num(1) assert_all(vals == 1) |