python - numpy all() evaluating incorrectly -


my code should stop when values of array greater 100. using np.all() evaluate condition. looks condition met, np.all() seems incorrectly evaluating. missing? python 2.7.8 on os 10.8.5.

(pdb) ratio_j_a array([ 250.44244741,  186.92848637,  202.67726408,  143.01112845,         132.95878384,  176.49130164,  178.9892571 ,  118.07516559,         205.59639112,  183.64142204]) (pdb) np.all(ratio_j_a) > 100. false  (pdb) np.all(ratio_j_a) < 100. true 

numpy.all tests whether array elements along given axis evaluate true.

>>> import numpy np >>> ratio_j_a = np.array([ ...     250.44244741,  186.92848637,  202.67726408,  143.01112845, ...     132.95878384,  176.49130164,  178.9892571 ,  118.07516559, ...     205.59639112,  183.64142204 ... ]) >>> np.all(ratio_j_a > 100) true >>> np.all(ratio_j_a < 100) false 

why got wrong result:

np.all(ratio_j_a) evaluated true because non-zero numbers treated truth value. , true equal 1. 1 > 100 false, 1 < 100 true.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -