Re: [Numpy-discussion] array allocation using tuples gives views of same array

2007-11-15 Thread George Nurser
On 15/11/2007, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > On Nov 15, 2007 9:11 AM, Hans Meine <[EMAIL PROTECTED]> wrote: > > Am Donnerstag, 15. November 2007 16:29:12 schrieb Warren Focke: > > > > > On Thu, 15 Nov 2007, George Nurser wrote: > > > > It looks to me like > > > > a,b = (zeros((2

[Numpy-discussion] array allocation using tuples gives views of same array

2007-11-15 Thread George Nurser
I tried the (as I thought) nice compact form In [60]: a,b = (zeros((2,)),)*2 But... In [61]: b[0] = 2 In [62]: a Out[62]: array([ 2., 0.]) a and b are the _same_ array But In [68]: a,b = (zeros((2,)),zeros((2,))) In [69]: b[0] = 2 In [70]: a Out[70]: array([ 0., 0.]) is OK. a & b are

Re: [Numpy-discussion] array allocation using tuples gives views of same array

2007-11-15 Thread Timothy Hochberg
On Nov 15, 2007 9:11 AM, Hans Meine <[EMAIL PROTECTED]> wrote: > Am Donnerstag, 15. November 2007 16:29:12 schrieb Warren Focke: > > On Thu, 15 Nov 2007, George Nurser wrote: > > > It looks to me like > > > a,b = (zeros((2,)),)*2 > > > is equivalent to > > > x= zeros((2,)) > > > a,b=(x,)*2 > > > >

Re: [Numpy-discussion] array allocation using tuples gives views of same array

2007-11-15 Thread Hans Meine
Am Donnerstag, 15. November 2007 16:29:12 schrieb Warren Focke: > On Thu, 15 Nov 2007, George Nurser wrote: > > It looks to me like > > a,b = (zeros((2,)),)*2 > > is equivalent to > > x= zeros((2,)) > > a,b=(x,)*2 > > Correct. > > > If this is indeed a feature rather than a bug, is there an alterna

Re: [Numpy-discussion] array allocation using tuples gives views of same array

2007-11-15 Thread Warren Focke
On Thu, 15 Nov 2007, George Nurser wrote: > It looks to me like > a,b = (zeros((2,)),)*2 > is equivalent to > x= zeros((2,)) > a,b=(x,)*2 Correct. > If this is indeed a feature rather than a bug, is there an alternative > compact way to allocate many arrays? a, b = [zeros((2,)) for x in range

Re: [Numpy-discussion] array allocation using tuples gives views of same array

2007-11-15 Thread Matthieu Brucher
It's not a question of tuple, you made a tuple, but in each element, you put the same array, so this behaviour is to be expected. Matthieu 2007/11/15, George Nurser <[EMAIL PROTECTED]>: > > I tried the (as I thought) nice compact form > In [60]: a,b = (zeros((2,)),)*2 > > But... > > In [61]: b[0]