[Numpy-discussion] efficient use of numpy.where() and .any()

Mark.Miller mpmusu at cc.usu.edu
Mon Apr 23 12:40:38 EDT 2007


Robert Kern wrote:
> Certainly. How about this?
> 
> mask = (a<0)
> a[mask] = numpy.random.normal(0, 1, size=mask.sum())
> 

That's slick.  I believe it's precisely what I'm after.

Appreciate it,

-Mark




More information about the NumPy-Discussion mailing list