Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cdef8d3

Browse files
committed
Merge pull request numpy#6628 from charris/fix-allclose-return-type
BUG: Make allclose return python bool.
2 parents 615e66b + a2435ae commit cdef8d3

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

doc/release/1.10.2-notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Issues Fixed
3333
* gh-6590 Fortran Array problem in numpy 1.10.
3434
* gh-6602 Random __all__ missing choice and dirichlet.
3535
* gh-6618 NPY_FORTRANORDER in make_fortran() in numpy.i
36+
* gh-6475 np.allclose returns a memmap when one of its arguments is a memmap.
3637

3738
Merged PRs
3839
==========
@@ -69,6 +70,7 @@ The following PRs in master have been backported to 1.10.2
6970
* gh-6606 DOC: Update 1.10.2 release notes.
7071
* gh-6614 BUG: Add choice and dirichlet to numpy.random.__all__.
7172
* gh-6621 BUG: Fix swig make_fortran function.
73+
* gh-6628 BUG: Make allclose return python bool.
7274

7375
Initial support for mingwpy was reverted as it was causing problems for
7476
non-windows builds.

numpy/core/numeric.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,8 @@ def allclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
22782278
True
22792279
22802280
"""
2281-
return all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan))
2281+
res = all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan))
2282+
return bool(res)
22822283

22832284
def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
22842285
"""

numpy/core/tests/test_numeric.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,16 @@ def test_equalnan(self):
14711471
x = np.array([1.0, np.nan])
14721472
assert_(np.allclose(x, x, equal_nan=True))
14731473

1474+
def test_return_class_is_ndarray(self):
1475+
# Issue gh-6475
1476+
# Check that allclose does not preserve subtypes
1477+
class Foo(np.ndarray):
1478+
def __new__(cls, *args, **kwargs):
1479+
return np.array(*args, **kwargs).view(cls)
1480+
1481+
a = Foo([1])
1482+
assert_(type(np.allclose(a, a)) is bool)
1483+
14741484

14751485
class TestIsclose(object):
14761486
rtol = 1e-5

0 commit comments

Comments
 (0)