summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/numeric.py6
-rw-r--r--numpy/core/tests/test_numeric.py14
2 files changed, 18 insertions, 2 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index a18b38072..0b728f804 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -2467,7 +2467,11 @@ def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
# Make NaN == NaN
both_nan = isnan(x) & isnan(y)
cond[both_nan] = both_nan[both_nan]
- return cond
+
+ if isscalar(a) and isscalar(b):
+ return bool(cond)
+ else:
+ return cond
def array_equal(a1, a2):
"""
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index a114d5a5a..17ea6212c 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -1589,7 +1589,11 @@ class TestIsclose(object):
def tst_isclose_allclose(self, x, y):
msg = "isclose.all() and allclose aren't same for %s and %s"
- assert_array_equal(np.isclose(x, y).all(), np.allclose(x, y), msg % (x, y))
+ msg2 = "isclose and allclose aren't same for %s and %s"
+ if np.isscalar(x) and np.isscalar(y):
+ assert_(np.isclose(x, y) == np.allclose(x, y), msg=msg % (x, y))
+ else:
+ assert_array_equal(np.isclose(x, y).all(), np.allclose(x, y), msg % (x, y))
def test_ip_all_isclose(self):
self.setup()
@@ -1650,6 +1654,14 @@ class TestIsclose(object):
assert_array_equal(x, np.array([np.inf, 1]))
assert_array_equal(y, np.array([0, np.inf]))
+ def test_non_finite_scalar(self):
+ # GH7014, when two scalars are compared the output should also be a
+ # scalar
+ assert_(np.isclose(np.inf, -np.inf) is False)
+ assert_(np.isclose(0, np.inf) is False)
+ assert_(type(np.isclose(0, np.inf)) is bool)
+
+
class TestStdVar(TestCase):
def setUp(self):
self.A = np.array([1, -1, 1, -1])