[Numpy-discussion] numpy.copyto alternative for previous versions than 1.7.0 ?

Sebastian Berg sebastian at sipsolutions.net
Fri Apr 11 06:05:22 EDT 2014


On Fr, 2014-04-11 at 02:36 -0700, techaddict wrote:
> Like how do i convert these to previous versions ?
> 
> copyto(ndarray(shape=[length], buffer=ba, offset=16, dtype="float64"), v)
> and
> copyto(ndarray(shape=[rows, cols], buffer=ba, offset=24, dtype="float64",
> order='C'), m)
> 
> 

First thing that comes to mind is using plain indexing which on versions
with copyto basically ends up calling copyto anyway if I remember
correctly (and v is an array, otherwise logic may be slightly more
complex for indexing).

So just using:

arr_view = ndarray(shape=[length], buffer=ba, offset=16, dtype="float64")
arr_view[...] = v

should do the trick.

- Sebastian

> 
> --
> View this message in context: http://numpy-discussion.10968.n7.nabble.com/numpy-copyto-alternative-for-previous-versions-than-1-7-0-tp37282p37283.html
> Sent from the Numpy-discussion mailing list archive at Nabble.com.
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 





More information about the NumPy-Discussion mailing list