[Numpy-discussion] summarizing blocks of an array using a moving window

Keith Goodman kwgoodman at gmail.com
Thu Jul 22 11:03:39 EDT 2010


On Thu, Jul 22, 2010 at 7:48 AM, Warren Weckesser
<warren.weckesser at enthought.com> wrote:

> Actually, because of the use of reshape(3,3,4), your second
> example does make a copy.

When does reshape return a view and when does it return a copy?

Here's a simple example that returns a view:

>> x = np.array([1,2,3,4])
>> y = x.reshape(2,2)
>> y[0,0] = 9
>> x
   array([9, 2, 3, 4])

What's a simple example that returns a copy?



More information about the NumPy-Discussion mailing list