On Wed, Aug 20, 2014 at 10:21 AM, Mika S <[email protected]> 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
IntPtr.__overloads__[int](a.__array_interface__['data'][0])def
marshal_to_ndarray(src): n = len(src) dest = np.empty(n,
dtype='f8')
Marshal.Copy(src, 0, ndarray_ptr(dest), n) return dest
Dave Cook
_________________________________________________
Python.NET mailing list - [email protected]
https://mail.python.org/mailman/listinfo/pythondotnet