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

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

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -