diff options
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/numeric.py | 3 | ||||
-rw-r--r-- | numpy/core/tests/test_numeric.py | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 4350e123f..2ece2ce8d 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -2278,7 +2278,8 @@ def allclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False): True """ - return all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan)) + res = all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan)) + return bool(res) def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False): """ diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index 2fa8593b9..f5c22392a 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -1471,6 +1471,16 @@ class TestAllclose(object): x = np.array([1.0, np.nan]) assert_(np.allclose(x, x, equal_nan=True)) + def test_return_class_is_ndarray(self): + # Issue gh-6475 + # Check that allclose does not preserve subtypes + class Foo(np.ndarray): + def __new__(cls, *args, **kwargs): + return np.array(*args, **kwargs).view(cls) + + a = Foo([1]) + assert_(type(np.allclose(a, a)) is bool) + class TestIsclose(object): rtol = 1e-5 |