Test a given array element-wise is finite or not using NumPy.

In this python numpy program, we will test a given array element-wise is finite or not using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array().
  3. Test whether a given array element-wise is finite or not using np.isfinite(),
  4. It will return True if an element is finite else False.
  5. Print the output.
				
					import numpy as np
x = np.array([6,8,3,np.inf])

print(np.isfinite(x))
				
			

Output :

				
					[ True  True  True False]
				
			

test whether none of the elements of a given array is zero.

test element-wise for NaN of a given array.

Leave a Comment