summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorJoe Kington <joferkington@gmail.com>2012-03-04 14:18:27 -0600
committerCharles Harris <charlesr.harris@gmail.com>2012-03-04 15:22:54 -0700
commitb9f0f1f8b54d0e4cf74ea5e7d80893d66585c4a1 (patch)
tree370d57b07a38d6ceb5c5a4bc071a5f7c317da948 /numpy/core/numeric.py
parent07e640c634ae7e7f859b3def5783e2e50b6002f4 (diff)
downloadnumpy-b9f0f1f8b54d0e4cf74ea5e7d80893d66585c4a1.tar.gz
ENH: Made "isclose()" NA-aware, added release note and versionadded.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index e4693431c..846429016 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -2059,6 +2059,8 @@ def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
Notes
-----
+ .. versionadded:: 1.7.0
+
For finite values, isclose uses the following equation to test whether
two floating point values are equivalent.
@@ -2090,17 +2092,18 @@ def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False):
y = array(b, copy=False, subok=True, ndmin=1)
xfin = isfinite(x)
yfin = isfinite(y)
- if all(xfin) and all(yfin):
+ if all(xfin, skipna=True) and all(yfin, skipna=True):
return within_tol(x, y, atol, rtol)
else:
finite = xfin & yfin
+ cond = zeros_like(finite, subok=True, maskna=finite.flags.maskna)
# Because we're using boolean indexing, x & y must be the same shape.
# Ideally, we'd just do x, y = broadcast_arrays(x, y). It's in
# lib.stride_tricks, though, so we can't import it here.
- cond = zeros_like(finite, subok=True)
x = x * ones_like(cond)
y = y * ones_like(cond)
- # Avoid subtraction with infinite/nan values...
+ # Avoid subtraction with infinite/nan values and indexing with na...
+ finite[isna(finite)] = False
cond[finite] = within_tol(x[finite], y[finite], atol, rtol)
# Check for equality of infinite values...
cond[~finite] = (x[~finite] == y[~finite])