bundles / numpy 2.4.3 / numpy / isreal
_ArrayFunctionDispatcher
numpy:isreal
Signature
def isreal ( x ) Summary
Returns a bool array, where True if input element is real.
Extended Summary
If element has complex type with zero imaginary part, the return value for that element is True.
Parameters
x: array_likeInput array.
Returns
out: ndarray, boolBoolean array of same shape as
x.
Notes
isreal may behave unexpectedly for string or object arrays (see examples)
Examples
import numpy as np a = np.array([1+1j, 1+0j, 4.5, 3, 2, 2j], dtype=complex) np.isreal(a)✓
a = np.array([2j, "a"], dtype="U")
✓np.isreal(a) # Warns about non-elementwise comparison
✗a = np.array([1, "2", 3+4j], dtype=object) np.isreal(a)✓
a = np.array([1+2j, 2+1j], dtype=object) np.isreal(a)✓
See also
- iscomplex
- isrealobj
Return True if x is not a complex type.
Aliases
-
numpy.isreal