python - Is there a nice way to check if numpy array elements are within a range? -


i want write:

assert np.all(0 < < 2) 

where a numpy array, doesn't work. what's nice way write this?

you use numpy.logical_and:

>>> = np.repeat(1, 10) >>> np.logical_and(a > 0, < 2).all() true 

or using &.

>>> ((0 < a) & (a < 2)).all() true 

Comments

Popular posts from this blog

javascript - Replicate keyboard event with html button -

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

Ansible warning on jinja2 braces on when -