summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/lib/ufunclike.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/numpy/lib/ufunclike.py b/numpy/lib/ufunclike.py
index 4d21cb820..6259c5445 100644
--- a/numpy/lib/ufunclike.py
+++ b/numpy/lib/ufunclike.py
@@ -11,6 +11,7 @@ import numpy.core.numeric as nx
import warnings
import functools
+
def _deprecate_out_named_y(f):
"""
Allow the out argument to be passed as the name `y` (deprecated)
@@ -81,6 +82,7 @@ def fix(x, out=None):
res = res[()]
return res
+
@_deprecate_out_named_y
def isposinf(x, out=None):
"""
@@ -139,11 +141,14 @@ def isposinf(x, out=None):
array([0, 0, 1])
"""
- x = nx.asanyarray(x)
- if nx.issubdtype(x.dtype, nx.complexfloating):
+ is_inf = nx.isinf(x)
+ try:
+ signbit = ~nx.signbit(x)
+ except TypeError:
raise TypeError('This operation is not supported for complex values '
'because it would be ambiguous.')
- return nx.logical_and(nx.isinf(x), ~nx.signbit(x), out)
+ else:
+ return nx.logical_and(is_inf, signbit, out)
@_deprecate_out_named_y
@@ -205,8 +210,11 @@ def isneginf(x, out=None):
array([1, 0, 0])
"""
- x = nx.asanyarray(x)
- if nx.issubdtype(x.dtype, nx.complexfloating):
+ is_inf = nx.isinf(x)
+ try:
+ signbit = nx.signbit(x)
+ except TypeError:
raise TypeError('This operation is not supported for complex values '
'because it would be ambiguous.')
- return nx.logical_and(nx.isinf(x), nx.signbit(x), out)
+ else:
+ return nx.logical_and(is_inf, signbit, out)