numpy.isrealobj(array) : This logical function helps to checks if the array has no complex type or array has a complex number. Even if imaginary part is equal to zero, it is not considered to be a Real Object.
Parameters :
array : [array_like]Input array or object whose elements, we need to test.
Return :
True, if the input array hasn't any complex element; otherwise False
Code 1 :
# Python program explaining # isrealobj() function import numpy as np in_array = [1, 3, 5, 4] print ("Input array : ", in_array) output_value = np.isrealobj(in_array) print ("\nIs real : ", output_value) |
chevron_right
filter_none
Output :
Input array : [1, 3, 5, 4] Is real : True
Code 2 :
# Python Program illustrating # numpy.isrealobj() method import numpy as geek # Returns True/False value for each element a = geek.arange(20).reshape(5, 4) print("Is real : ", geek.isrealobj(a)) # Returns True/False value as ans # because we have mentioned dtpe in the beginning b = geek.arange(20).reshape(5, 4).dtype = complex print("\n",b) print("\nIs real : ", geek.isrealobj(b)) b = [[1j], [3]] print("\nIs real : ", geek.isrealobj(b)) |
chevron_right
filter_none
Output :
Is real : True class 'complex' Is real : True Is real : False
References :
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.isrealobj.html#numpy.isrealobj
.
Recommended Posts:
- Reusable piece of python functionality for wrapping arbitrary blocks of code : Python Context Managers
- Python - Read blob object in python using wand library
- Python | Convert list to Python array
- Reading Python File-Like Objects from C | Python
- Important differences between Python 2.x and Python 3.x with examples
- twitter-text-python (ttp) module - Python
- MySQL-Connector-Python module in Python
- Python | Index of Non-Zero elements in Python list
- Python | Merge Python key values to list
- Python | PRAW - Python Reddit API Wrapper
- Python | Add Logging to a Python Script
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Add Logging to Python Libraries
- Python | Sort Python Dictionaries by Key or Value
- Python | Visualizing O(n) using Python
- JavaScript vs Python : Can Python Overtop JavaScript by 2020?
- set add() in python
- Use of min() and max() in Python
- Python Try Except
- chr() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai

