summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorJoshua Loyal <joshua.d.loyal@gmail.com>2017-02-19 12:04:27 -0500
committerJoshua Loyal <joshua.d.loyal@gmail.com>2017-02-20 11:51:39 -0500
commit89944e80e6fc9bc47d1666b9a7572827138f90e3 (patch)
treef96157cea8d789a13b65e7a3f8e31e03b3b5d555 /numpy/lib/tests
parenteda7009cf14a9b8e9b03ddd5a8ec369646c8525d (diff)
downloadnumpy-89944e80e6fc9bc47d1666b9a7572827138f90e3.tar.gz
ENH: Allow for an in-place nan_to_num conversion. Fixes #8634
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_type_check.py10
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)