In this python numpy program, we will test a given array element-wise is finite or not using NumPy.
Steps to solve the program
- Import the numpy library as np.
- Create an array using np.array().
- Test whether a given array element-wise is finite or not using np.isfinite(),
- It will return True if an element is finite else False.
- Print the output.
import numpy as np
x = np.array([6,8,3,np.inf])
print(np.isfinite(x))
Output :
[ True True True False]