summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-02-05 10:03:07 -0700
committerGitHub <noreply@github.com>2021-02-05 10:03:07 -0700
commit6373ded2ed1403cc3ec40dc5d919b316a1b58e44 (patch)
tree7ad84d4f27c8fe8f8eac5f9213fdbf1dc4b58e4f /numpy/core/numeric.py
parent2b7be2005f3d74141f9f8e83be603be0ddbe7046 (diff)
parentbcb168a56d1c47b877568ce51ce90a1ced89f007 (diff)
downloadnumpy-6373ded2ed1403cc3ec40dc5d919b316a1b58e44.tar.gz
Merge pull request #18329 from seberg/issue-18286
BUG: Allow unmodified use of isclose, allclose, etc. with timedelta
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 086439656..89f56fa09 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -2350,8 +2350,13 @@ def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
# Make sure y is an inexact type to avoid bad behavior on abs(MIN_INT).
# This will cause casting of x later. Also, make sure to allow subclasses
# (e.g., for numpy.ma).
- dt = multiarray.result_type(y, 1.)
- y = array(y, dtype=dt, copy=False, subok=True)
+ # NOTE: We explicitly allow timedelta, which used to work. This could
+ # possibly be deprecated. See also gh-18286.
+ # timedelta works if `atol` is an integer or also a timedelta.
+ # Although, the default tolerances are unlikely to be useful
+ if y.dtype.kind != "m":
+ dt = multiarray.result_type(y, 1.)
+ y = array(y, dtype=dt, copy=False, subok=True)
xfin = isfinite(x)
yfin = isfinite(y)