I want to start an if condition checking all elements in a previously defined array, for example:
import numpy as np
f = np.zeros(5)
if f[i]<100
#do something
where i is supposed to check all the elements of f. I believe there is an easy way to do this in python instead of creating a loop searching all elements, any help would be appreciated. Thanks in advance.
Edit: I tried to use the numpy.any() function but it seems is not working the way I thought, for example:
import numpy as np
z = np.array([1, 2000, 30000])
if np.any(z)>2:
print('Something')
But the results return False
Aucun commentaire:
Enregistrer un commentaire