summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Lee <anntzer.lee@gmail.com>2016-03-30 19:10:26 -0700
committerAntony Lee <anntzer.lee@gmail.com>2016-03-30 19:10:26 -0700
commit9fba2cb5ebddd4790be60801aa0aa62027fbfd02 (patch)
treec56e63a8b68cefe66c817de183965d3cc99081ab
parent25d60a989766e630b92a79284388845ade96d3d0 (diff)
downloadnumpy-9fba2cb5ebddd4790be60801aa0aa62027fbfd02.tar.gz
Faster real_if_close.
Because of the complexity of `allclose`, `real_if_close(t)` used to be ~2.5-3x slower than, say, `t + t`. This patch makes it approximately as fast.
-rw-r--r--numpy/lib/type_check.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py
index 1313adff7..d6e0704ad 100644
--- a/numpy/lib/type_check.py
+++ b/numpy/lib/type_check.py
@@ -424,7 +424,7 @@ def real_if_close(a,tol=100):
from numpy.core import getlimits
f = getlimits.finfo(a.dtype.type)
tol = f.eps * tol
- if _nx.allclose(a.imag, 0, atol=tol):
+ if _nx.all(_nx.absolute(a.imag) < tol):
a = a.real
return a