Re: [Numpy-discussion] masked index surprise

2009-08-14 Thread Keith Goodman
On Fri, Aug 14, 2009 at 12:24 PM, Robert Kern wrote: > On Fri, Aug 14, 2009 at 14:20, Keith Goodman wrote: >> On Fri, Aug 14, 2009 at 11:52 AM, Robert Kern wrote: >>> On Fri, Aug 14, 2009 at 13:05, John Hunter wrote: I just tracked down a subtle bug in my code, which is equivalent to

Re: [Numpy-discussion] masked index surprise

2009-08-14 Thread Robert Kern
On Fri, Aug 14, 2009 at 14:20, Keith Goodman wrote: > On Fri, Aug 14, 2009 at 11:52 AM, Robert Kern wrote: >> On Fri, Aug 14, 2009 at 13:05, John Hunter wrote: >>> I just tracked down a subtle bug in my code, which is equivalent to >>> >>> >>> In [64]: x, y = np.random.rand(2, n) >>> >>> In [65]: z

Re: [Numpy-discussion] masked index surprise

2009-08-14 Thread Keith Goodman
On Fri, Aug 14, 2009 at 11:52 AM, Robert Kern wrote: > On Fri, Aug 14, 2009 at 13:05, John Hunter wrote: >> I just tracked down a subtle bug in my code, which is equivalent to >> >> >> In [64]: x, y = np.random.rand(2, n) >> >> In [65]: z = np.zeros_like(x) >> >> In [66]: mask = x>0.5 >> >> In [67]

Re: [Numpy-discussion] masked index surprise

2009-08-14 Thread Robert Kern
On Fri, Aug 14, 2009 at 13:05, John Hunter wrote: > I just tracked down a subtle bug in my code, which is equivalent to > > > In [64]: x, y = np.random.rand(2, n) > > In [65]: z = np.zeros_like(x) > > In [66]: mask = x>0.5 > > In [67]: z[mask] = x/y > > > > I meant to write > >  z[mask] = x[mask]/y

[Numpy-discussion] masked index surprise

2009-08-14 Thread John Hunter
I just tracked down a subtle bug in my code, which is equivalent to In [64]: x, y = np.random.rand(2, n) In [65]: z = np.zeros_like(x) In [66]: mask = x>0.5 In [67]: z[mask] = x/y I meant to write z[mask] = x[mask]/y[mask] so I can fix my code, but why is line 67 allowed In [68]: z[m