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



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/numpy/logic-functions/isrealobj.php