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

Mark.Miller mpmusu@cc.usu....
Mon Apr 23 11:40:38 CDT 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