Merge pull request #3761 from nicoddemus/numpy-recursion-error

Fix recursion in pytest.approx() with arrays in numpy<1.13
This commit is contained in:
Bruno Oliveira 2018-08-01 23:40:30 -03:00 committed by GitHub
commit 5db2e6c7a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix infinite recursion in ``pytest.approx`` with arrays in ``numpy<1.13``.

View File

@ -257,7 +257,9 @@ class ApproxScalar(ApproxBase):
the pre-specified tolerance.
"""
if _is_numpy_array(actual):
return all(a == self for a in actual.flat)
# Call ``__eq__()`` manually to prevent infinite-recursion with
# numpy<1.13. See #3748.
return all(self.__eq__(a) for a in actual.flat)
# Short-circuit exact equality.
if actual == self.expected: