Re: [Numpy-discussion] copying array to itself

2012-05-03 Thread Stéfan van der Walt
On Thu, May 3, 2012 at 1:51 AM, Henry Gomersall wrote: > Right, so this is expected behaviour then. Is this documented somewhere? > It strikes me that this is pretty unexpected behaviour. Imagine the way you would code this in a for-loop. You want a = np.arange(10) a[2:] = a[:-2] Now you write

Re: [Numpy-discussion] copying array to itself

2012-05-03 Thread Henry Gomersall
On Wed, 2012-05-02 at 12:58 -0700, Stéfan van der Walt wrote: > On Wed, May 2, 2012 at 9:03 AM, Henry Gomersall > wrote: > > Is this some nuance of the way numpy does things? Or am I missing > some > > stupid bug in my code? > > Try playing with the parameters of the following code: > > > For

Re: [Numpy-discussion] copying array to itself

2012-05-02 Thread Stéfan van der Walt
On Wed, May 2, 2012 at 9:03 AM, Henry Gomersall wrote: > Is this some nuance of the way numpy does things? Or am I missing some > stupid bug in my code? Try playing with the parameters of the following code: sz = 1 N = 10 import numpy as np x = np.arange(sz) y = x.copy() x[:-N] = x[N:] np

[Numpy-discussion] copying array to itself

2012-05-02 Thread Henry Gomersall
I'm need to do some shifting of data within an array and am using the following code: for p in numpy.arange(array.shape[0], dtype='int64'): for q in numpy.arange(array.shape[1]): # A positive shift is towards zero shift = shift_values[p, q] if shift >= 0: