summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Kington <joferkington@gmail.com>2012-03-04 11:34:35 -0600
committerCharles Harris <charlesr.harris@gmail.com>2012-03-04 15:06:29 -0700
commitd292acd4cb3ff6928b2cc211e220d664e96e820f (patch)
tree4420d38d457eed2a55f95c4063ba9326ef70b97b
parent56e3e526e026125ba16d30339c4411042b950b06 (diff)
downloadnumpy-d292acd4cb3ff6928b2cc211e220d664e96e820f.tar.gz
TST: Added masked array and scalar tests for "isclose()".
-rw-r--r--numpy/core/tests/test_numeric.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index 7c1ba2dba..a559da1b3 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -1233,12 +1233,14 @@ class TestIsclose(object):
(arange(3), [0, 1, 2.1]),
(nan, [nan, nan, nan]),
([0], [atol, inf, -inf, nan]),
+ (0, [atol, inf, -inf, nan]),
]
results = [[True, False],
[True, False, False],
[True, True, False],
[False, False, False],
[True, False, False, False],
+ [True, False, False, False],
]
for (x, y), result in zip(tests, results):
@@ -1295,6 +1297,22 @@ class TestIsclose(object):
arr = array([1.0, nan])
assert_array_equal(isclose(arr, arr, equal_nan=True), [True, True])
+ def test_masked_arrays(self):
+ x = np.ma.masked_where([True, True, False], np.arange(3))
+ assert_(type(x) == type(isclose(2, x)))
+
+ x = np.ma.masked_where([True, True, False], [nan, inf, nan])
+ assert_(type(x) == type(isclose(inf, x)))
+
+ x = np.ma.masked_where([True, True, False], [nan, nan, nan])
+ y = isclose(nan, x, equal_nan=True)
+ assert_(type(x) == type(y))
+ # Ensure that the mask isn't modified...
+ assert_array_equal([True, True, False], y.mask)
+
+ def test_scalar_return(self):
+ assert_(isscalar(isclose(1, 1)))
+
def test_no_parameter_modification(self):
x = array([inf, 1])
y = array([0, inf])