[Numpy-discussion] dimension independent copy of corner of array
ndbecker2 at gmail.com
Mon Jul 13 08:21:34 EDT 2015
Robert Kern wrote:
> newarr[tuple(slice(0, i) for i in oldarray.shape)] = oldarray
> On Mon, Jul 13, 2015 at 12:34 PM, Neal Becker <ndbecker2 at gmail.com> wrote:
>> I want to copy an array to the corner of a new array. What is a
>> dimension independent way to say:
>> newarr[:i0,:i1,...] = oldarray
>> where (i0,i1...) is oldarray.shape?
Thanks. I'm making my own class that represents a resizeable array that
works by preserving the lower corner of the old data, because I believe that
ndarray arr.resize does not actually work this way. I'm only interested in
resizing to a larger size. Is this correct?
More information about the NumPy-Discussion