[Python.NET] converting double array to numpy list

Dave Cook daverz at gmail.com
Sat Aug 23 16:28:27 CEST 2014

On Wed, Aug 20, 2014 at 10:21 AM, Mika S <siddhupiddu at gmail.com> wrote:

How do I pass a double array as a numpy list from C# (calling python code
> from c#) or passing something that can become a numpy list with minimal
> overhead.
Based on input from an earlier thread here, I settled on using Marshal.Copy:

def ndarray_ptr(a):    '''Return a .NET pointer to the underlying
ndarray data.'''    return
marshal_to_ndarray(src):    n = len(src)    dest = np.empty(n,
    Marshal.Copy(src, 0, ndarray_ptr(dest), n)    return dest

Dave Cook
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20140823/2c026226/attachment.html>

More information about the PythonDotNet mailing list