summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorMary <sleeplessinseattle.dev@gmail.com>2021-02-17 19:48:22 -0800
committerMary <sleeplessinseattle.dev@gmail.com>2021-02-17 19:48:22 -0800
commitc902caf7c66bf0657ce8ae0987f72adbaadebd22 (patch)
treec2b888a8428d5458429d5b9a540cfb427904dda5 /numpy/core/numeric.py
parentdca0d1c928665464b137419f0f530d5a6aac8ebd (diff)
parent0eb9f54e5e466c8d7a76ae116712b368d045c7e0 (diff)
downloadnumpy-c902caf7c66bf0657ce8ae0987f72adbaadebd22.tar.gz
Merge branch 'master' of https://github.com/numpy/numpy into iss17845p3a
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 086439656..7675386e7 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -710,6 +710,7 @@ def correlate(a, v, mode='valid'):
--------
convolve : Discrete, linear convolution of two one-dimensional sequences.
multiarray.correlate : Old, no conjugate, version of correlate.
+ scipy.signal.correlate : uses FFT which has superior performance on large arrays.
Notes
-----
@@ -720,6 +721,11 @@ def correlate(a, v, mode='valid'):
which is related to ``c_{av}[k]`` by ``c'_{av}[k] = c_{av}[-k]``.
+ `numpy.correlate` may perform slowly in large arrays (i.e. n = 1e5) because it does
+ not use the FFT to compute the convolution; in that case, `scipy.signal.correlate` might
+ be preferable.
+
+
Examples
--------
>>> np.correlate([1, 2, 3], [0, 1, 0.5])
@@ -2350,8 +2356,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)