Re: [Numpy-discussion] Putmask/take ?

2006-09-22 Thread Travis Oliphant
Travis Oliphant wrote: >Yes, this does explain what you are seeing.It is the behavior of >Numeric's putmask (where this method came from). It does seem >counter-intuitive, and I'm not sure what to do with it. In some sense >putmask should behave the same as x[m] = w. But, on the other-

Re: [Numpy-discussion] putmask/take ?

2006-09-22 Thread PGM
Stefan, Thanks for your suggestions, but that won't do for what I'm working on : I need to get putmask working, or at least knowing it doesnt'. Robert, thanks for your input. The function putmask doesn't work either. Oh, thinking about it: would it be possible to have the same order of arguments

Re: [Numpy-discussion] Putmask/take ?

2006-09-22 Thread Travis Oliphant
Stefan van der Walt wrote: > On Fri, Sep 22, 2006 at 02:17:57AM -0500, Robert Kern wrote: > >>> 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

Re: [Numpy-discussion] Putmask/take ?

2006-09-22 Thread Stefan van der Walt
On Fri, Sep 22, 2006 at 02:17:57AM -0500, Robert Kern wrote: > Stefan van der Walt wrote: > > 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 = [

Re: [Numpy-discussion] Putmask/take ?

2006-09-22 Thread Robert Kern
Stefan van der Walt wrote: > 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([

Re: [Numpy-discussion] putmask/take ?

2006-09-22 Thread Stefan van der Walt
On Thu, Sep 21, 2006 at 08:35:02PM -0400, P GM wrote: > Folks, > 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(

Re: [Numpy-discussion] Putmask/take ?

2006-09-22 Thread Stefan van der Walt
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,

[Numpy-discussion] Putmask/take ?

2006-09-21 Thread PGM
Folks, 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) False I'm wondering if

[Numpy-discussion] putmask/take ?

2006-09-21 Thread P GM
Folks,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)FalseI'm wondering ifit is intentio