numpy.isreal() in Python
numpy.isreal(array) : Test element-wise whether it is a real number or not(not infinity or not Not a Number) and return the result as a boolean array.
Parameters :
array : [array_like] Input array whose element we want to test
Return :
boolean array containing the result
Code 1 :
# Python Program illustrating # numpy.isreal() method import numpy as geek print("Is Real : ", geek.isreal([1+1j, 0j]), "\n") print("Is Real : ", geek.isreal([1, 0]), "\n") |
Output :
Is Real : [False True] Is Real : [ True True]
Code 2 :
# Python Program illustrating # numpy.isreal() method import numpy as geek # Returns True/False value for each element a = geek.arange(20).reshape(5, 4) print("Is Real : \n", geek.isreal(a), "\n") # Returns True/False value as ans # because we have mentioned dtpe in the beginning a = geek.arange(20).reshape(5, 4).dtype = floatprint("\nIs Real : ", geek.isreal(a)) |
Output :
Is Real : [[ True True True True] [ True True True True] [ True True True True] [ True True True True] [ True True True True]] Is Real : True
References :
https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.isreal.html#numpy.isreal
Note :
These codes won’t run on online-ID. Please run them on your systems to explore the working
.
This article is contributed by Mohit Gupta_OMG 😀. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Recommended Posts:
- Python | Index of Non-Zero elements in Python list
- Python | Merge Python key values to list
- Python | Convert list to Python array
- Important differences between Python 2.x and Python 3.x with examples
- Reading Python File-Like Objects from C | Python
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- Python | Visualizing O(n) using Python
- JavaScript vs Python : Can Python Overtop JavaScript by 2020?
- Any & All in Python
- Python vs PHP
- max() and min() in Python
- Python Set | pop()
Improved By : Akanksha_Rai



