Q:

Write a NumPy program to test a given array element-wise for finiteness (not infinity or not a Number)

0

Write a NumPy program to test a given array element-wise for finiteness (not infinity or not a Number).

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
a = np.array([1, 0, np.nan, np.inf])
print("Original array")
print(a)
print("Test a given array element-wise for finiteness :")
print(np.isfinite(a))

Sample Output:

Original array
[  1.   0.  nan  inf]
Test a given array element-wise for finiteness :
[ True  True False False]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now