diff options
| author | Joscha Reimer <jor@informatik.uni-kiel.de> | 2018-07-26 10:26:39 +0200 |
|---|---|---|
| committer | Joscha Reimer <jor@informatik.uni-kiel.de> | 2018-07-26 11:06:15 +0200 |
| commit | dd7701d07387fca225c429f0e79cca661d44652b (patch) | |
| tree | f4647a430aaa5e57a28aac7fa3f8fa7bccff12e2 /numpy | |
| parent | 18e138c6b5a169750b995d826a8bee8e4918c9af (diff) | |
| download | numpy-dd7701d07387fca225c429f0e79cca661d44652b.tar.gz | |
BUG: isposinf and isneginf now raise an exception for complex values
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/lib/ufunclike.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/numpy/lib/ufunclike.py b/numpy/lib/ufunclike.py index e0bd95182..0d309e0e6 100644 --- a/numpy/lib/ufunclike.py +++ b/numpy/lib/ufunclike.py @@ -116,8 +116,9 @@ def isposinf(x, out=None): NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). - Errors result if the second argument is also supplied when `x` is a - scalar input, or if first and second arguments have different shapes. + Errors result if the second argument is also supplied when x is a scalar + input, if first and second arguments have different shapes, or if the + first argument as complex values Examples -------- @@ -138,6 +139,10 @@ def isposinf(x, out=None): array([0, 0, 1]) """ + x = nx.asanyarray(x) + if nx.issubdtype(x.dtype, nx.complexfloating): + raise ValueError('This operation is not supported for complex values' + 'because it would be ambiguous.') return nx.logical_and(nx.isinf(x), ~nx.signbit(x), out) @@ -178,7 +183,8 @@ def isneginf(x, out=None): (IEEE 754). Errors result if the second argument is also supplied when x is a scalar - input, or if first and second arguments have different shapes. + input, if first and second arguments have different shapes, or if the + first argument as complex values. Examples -------- @@ -199,4 +205,8 @@ def isneginf(x, out=None): array([1, 0, 0]) """ + x = nx.asanyarray(x) + if nx.issubdtype(x.dtype, nx.complexfloating): + raise ValueError('This operation is not supported for complex values' + 'because it would be ambiguous.') return nx.logical_and(nx.isinf(x), nx.signbit(x), out) |
