Skip to content

Commit e2812ed

Browse files
committed
TST: Update unittests for allclose, isclose.
1 parent e1d3a0c commit e2812ed

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

numpy/core/tests/test_numeric.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,11 @@ def test_min_int(self):
15741574
assert_(allclose(a, a))
15751575

15761576

1577+
def test_equalnan(self):
1578+
x = np.array([1.0, np.nan])
1579+
assert_(allclose(x, x, equal_nan=True))
1580+
1581+
15771582
class TestIsclose(object):
15781583
rtol = 1e-5
15791584
atol = 1e-8
@@ -1664,17 +1669,25 @@ def test_equal_nan(self):
16641669
assert_array_equal(isclose(arr, arr, equal_nan=True), [True, True])
16651670

16661671
def test_masked_arrays(self):
1672+
# Make sure to test the output type when arguments are interchanged.
1673+
16671674
x = np.ma.masked_where([True, True, False], np.arange(3))
16681675
assert_(type(x) is type(isclose(2, x)))
1676+
assert_(type(x) is type(isclose(x, 2)))
16691677

16701678
x = np.ma.masked_where([True, True, False], [nan, inf, nan])
16711679
assert_(type(x) is type(isclose(inf, x)))
1680+
assert_(type(x) is type(isclose(x, inf)))
16721681

16731682
x = np.ma.masked_where([True, True, False], [nan, nan, nan])
16741683
y = isclose(nan, x, equal_nan=True)
16751684
assert_(type(x) is type(y))
16761685
# Ensure that the mask isn't modified...
16771686
assert_array_equal([True, True, False], y.mask)
1687+
y = isclose(x, nan, equal_nan=True)
1688+
assert_(type(x) is type(y))
1689+
# Ensure that the mask isn't modified...
1690+
assert_array_equal([True, True, False], y.mask)
16781691

16791692
x = np.ma.masked_where([True, True, False], [nan, nan, nan])
16801693
y = isclose(x, x, equal_nan=True)

0 commit comments

Comments
 (0)