[Numpy-discussion] Array views

Hugo Gagnon sourceforge.numpy at user.fastmail.fm
Sat Mar 26 13:10:42 EDT 2011


Hello,

Say I have a few 1d arrays and one 2d array which columns I want to be
the 1d arrays.
I also want all the a's arrays to share the *same data* with the b
array.
If I call my 1d arrays a1, a2, etc. and my 2d array b, then

b[:,0] = a1[:]
b[:,1] = a2[:]
...

won't work because apparently copying occurs.
I tried it the other way around i.e.

a1 = b[:,0]
a2 = b[:,1]
...

and it works but that doesn't help me for my problem.
Is there a way to reformulate the first code snippet above but with
shallow copying?

Thanks,
--
  Hugo Gagnon
--
  Hugo Gagnon




More information about the NumPy-Discussion mailing list