lundi 27 avril 2015

Python - test all values in array against scalar value

I am trying to compare values in a numpy array with a scalar value. Here is an example of this array. If it's any help it can only contain positive values.

y = np.array([ 1 , 0.008 , 3 , 4 , 5])

In another section of my code I want to compare this array with a scalar, say 3.5 in an 'if' statement used to break while loop. I want to test if ANY of the values in the array is larger then this scalar value.

while True:

    if any_value_in_array(y) > 3.5
       break

    #random code

Any command that would enable me of doing something like that?

Aucun commentaire:

Enregistrer un commentaire