Discussion:
[Numpy-discussion] dimension independent copy of corner of array
Neal Becker
2015-07-13 11:34:27 UTC
Permalink
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?
Robert Kern
2015-07-13 11:38:37 UTC
Permalink
newarr[tuple(slice(0, i) for i in oldarray.shape)] = oldarray
Post by Neal Becker
I want to copy an array to the corner of a new array. What is a dimension
newarr[:i0,:i1,...] = oldarray
where (i0,i1...) is oldarray.shape?
_______________________________________________
NumPy-Discussion mailing list
http://mail.scipy.org/mailman/listinfo/numpy-discussion
--
Robert Kern
Neal Becker
2015-07-13 12:21:34 UTC
Permalink
Post by Robert Kern
newarr[tuple(slice(0, i) for i in oldarray.shape)] = oldarray
Post by Neal Becker
I want to copy an array to the corner of a new array. What is a
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?

Loading...