Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

NumPy Logic functions: isrealobj() function

numpy.isrealobj() function

The isrealobj() function is used to 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,
isrealobj evaluates to False if the data type is complex.

Syntax:

numpy.isrealobj(x)

Version: 1.15.0

Parameter:

Name Description Required /
Optional
x The input can be of any type and shape.
any
Required

Returns:
y: bool - The return value, False if x is of a complex type.

NumPy.isrealobj() method Example-1:

>>> import numpy as np
>>> np.isrealobj(2)

Output:

True

NumPy.isrealobj() method Example-2:

>>> import numpy as np
>>> np.isrealobj(2+0j)

Output:

False

NumPy.isrealobj() method Example-3:

>>> import numpy as np
>>> np.isrealobj([4, 1+0j, True])

Output:

False

Python - NumPy Code Editor:

Previous: isreal() function
Next: isscalar() function