Open lelelemonade opened 4 years ago
Added some changes that will make sure the NDarray will hold reference to the NDArray as long as the PyObject doesnt change internally.
Remember! you have to keep reference to the original NDArray, otherwise the NDArray will be disposed and will release the memory. (@henon is there a tag field we can use in NDarray?)
Not yet, but I will add one in Numpy.NET and support this.
Hi, could you provide instruction on how to use the ConsoleApp9.zip? And does it able to convert Numpy array back to NumSharp array?
@davidvct, if I remember correctly I have added support for copying data to and from Numpy.NET like @Nucs did in this solution. Read this to see how: https://github.com/SciSharp/Numpy.NET#create-a-numpy-array-from-a-c-array-and-vice-versa
Me and @henon have collaborated just two days ago on a solution for that, The trick is to create a python scope, load a script that takes in a pointer-length and returns an np.ndarray Remember! you have to keep reference to the original NDArray, otherwise the NDArray will be disposed and will release the memory. (@henon is there a tag field we can use in NDarray?)
Note: the code below is psuedo, the rest of the code can be found here: ConsoleApp9.zip
numpy_interop.py as embedded resource
PythonExtensions.cs
main.cs