summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/umath/loops_exponent_log.dispatch.c.src2
-rw-r--r--numpy/core/tests/test_ufunc.py2
-rw-r--r--numpy/lib/type_check.py26
3 files changed, 27 insertions, 3 deletions
diff --git a/numpy/core/src/umath/loops_exponent_log.dispatch.c.src b/numpy/core/src/umath/loops_exponent_log.dispatch.c.src
index 291ce4518..41e0bf37b 100644
--- a/numpy/core/src/umath/loops_exponent_log.dispatch.c.src
+++ b/numpy/core/src/umath/loops_exponent_log.dispatch.c.src
@@ -776,7 +776,7 @@ AVX512F_exp_DOUBLE(npy_double * op,
nearzero_mask = _mm512_kxor(nearzero_mask, nan_mask);
overflow_mask = _mm512_kor(overflow_mask,
_mm512_kxor(xmax_mask, inf_mask));
- underflow_mask = _mm512_kor(underflow_mask, xmax_mask);
+ underflow_mask = _mm512_kor(underflow_mask, xmin_mask);
x = avx512_set_masked_lanes_pd(x, zeros_d,
_mm512_kor(_mm512_kor(nan_mask, xmin_mask),
_mm512_kor(xmax_mask, nearzero_mask)));
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py
index c13865ce4..64ecb3780 100644
--- a/numpy/core/tests/test_ufunc.py
+++ b/numpy/core/tests/test_ufunc.py
@@ -175,7 +175,7 @@ class TestUfuncGenericLoops:
ufunc(obj_arr)
else:
res_obj = ufunc(obj_arr)
- assert_array_equal(res_num.astype("O"), res_obj)
+ assert_array_almost_equal(res_num.astype("O"), res_obj)
def _pickleable_module_global():
diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py
index 2a2982ab3..383fbda3c 100644
--- a/numpy/lib/type_check.py
+++ b/numpy/lib/type_check.py
@@ -262,6 +262,10 @@ def isreal(x):
out : ndarray, bool
Boolean array of same shape as `x`.
+ Notes
+ -----
+ `isreal` may behave unexpectedly for string or object arrays (see examples)
+
See Also
--------
iscomplex
@@ -269,8 +273,28 @@ def isreal(x):
Examples
--------
- >>> np.isreal([1+1j, 1+0j, 4.5, 3, 2, 2j])
+ >>> a = np.array([1+1j, 1+0j, 4.5, 3, 2, 2j], dtype=complex)
+ >>> np.isreal(a)
array([False, True, True, True, True, False])
+
+ The function does not work on string arrays.
+
+ >>> a = np.array([2j, "a"], dtype="U")
+ >>> np.isreal(a) # Warns about non-elementwise comparison
+ False
+
+ Returns True for all elements in input array of ``dtype=object`` even if
+ any of the elements is complex.
+
+ >>> a = np.array([1, "2", 3+4j], dtype=object)
+ >>> np.isreal(a)
+ array([ True, True, True])
+
+ isreal should not be used with object arrays
+
+ >>> a = np.array([1+2j, 2+1j], dtype=object)
+ >>> np.isreal(a)
+ array([ True, True])
"""
return imag(x) == 0