Hi P., On Thu, Sep 21, 2006 at 07:40:39PM -0400, PGM wrote:
> I'm running into the following problem with putmask on take. > > >>> import numpy > >>> x = N.arange(12.) > >>> m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1] > >>> i = N.nonzero(m)[0] > >>> w = N.array([-1, -2, -3, -4.]) > >>> x.putmask(w,m) > >>> x.take(i) > >>> N.allclose(x.take(i),w) According to the putmask docstring: a.putmask(values, mask) sets a.flat[n] = v[n] for each n where mask.flat[n] is true. v can be scalar. This would mean that 'w' is not of the right length. Would the following do what you want? import numpy as N m = N.array([1,0,0,0,0,0,1,0,0,1,0,1],dtype=bool) w = N.array([-1,-2,-3,-4]) x[m] = w Regards Stéfan ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion