Learn | NEPs | User Guide | API reference | Building from source | Development | Release notes | NumPy’s module structure | Array objects | Universal functions (ufunc) | Routines and objects by topic | Constants | Bit-wise operations | String functionality | Data type routines | Floating point error handling | Discrete Fourier Transform | Input and output | Linear algebra | Logic functions | Masked array operations | Mathematical functions | Miscellaneous routines | Random sampling | Set routines | Sorting, searching, and counting | Test support | Window functions
numpy.isrealobj(x)
Return True if x is a not complex type or an array of complex numbers.
The type of the input is checked, not the value. So even if the input has an imaginary part equal to zero,
evaluates to False if the data type is complex.
Parameters:xanyThe input can be of any type and shape.
Returns:yboolThe return value, False if x is of a complex type.
Notes
The function is only meant for arrays with numerical values but it accepts all other objects. Since it assumes array input, the return value of other objects may be True.
>>> np.isrealobj('A string')True>>> np.isrealobj(False)True>>> np.isrealobj(None)TrueExamples
>>> importnumpyasnp>>> np.isrealobj(1)True>>> np.isrealobj(1+0j)False>>> np.isrealobj([3,1+0j,True])False