@@ -1574,6 +1574,11 @@ def test_min_int(self):
1574
1574
assert_ (allclose (a , a ))
1575
1575
1576
1576
1577
+ def test_equalnan (self ):
1578
+ x = np .array ([1.0 , np .nan ])
1579
+ assert_ (allclose (x , x , equal_nan = True ))
1580
+
1581
+
1577
1582
class TestIsclose (object ):
1578
1583
rtol = 1e-5
1579
1584
atol = 1e-8
@@ -1664,17 +1669,25 @@ def test_equal_nan(self):
1664
1669
assert_array_equal (isclose (arr , arr , equal_nan = True ), [True , True ])
1665
1670
1666
1671
def test_masked_arrays (self ):
1672
+ # Make sure to test the output type when arguments are interchanged.
1673
+
1667
1674
x = np .ma .masked_where ([True , True , False ], np .arange (3 ))
1668
1675
assert_ (type (x ) is type (isclose (2 , x )))
1676
+ assert_ (type (x ) is type (isclose (x , 2 )))
1669
1677
1670
1678
x = np .ma .masked_where ([True , True , False ], [nan , inf , nan ])
1671
1679
assert_ (type (x ) is type (isclose (inf , x )))
1680
+ assert_ (type (x ) is type (isclose (x , inf )))
1672
1681
1673
1682
x = np .ma .masked_where ([True , True , False ], [nan , nan , nan ])
1674
1683
y = isclose (nan , x , equal_nan = True )
1675
1684
assert_ (type (x ) is type (y ))
1676
1685
# Ensure that the mask isn't modified...
1677
1686
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 )
1678
1691
1679
1692
x = np .ma .masked_where ([True , True , False ], [nan , nan , nan ])
1680
1693
y = isclose (x , x , equal_nan = True )
0 commit comments