Skip to content

best way to convert ndarray to a .net #652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
user015 opened this issue Mar 27, 2018 · 5 comments
Closed

best way to convert ndarray to a .net #652

user015 opened this issue Mar 27, 2018 · 5 comments

Comments

@user015
Copy link

user015 commented Mar 27, 2018

Is there a efficient way to convert numpy.ndarray to a .net object (array/list) ? I have a 2D ndarray that is pretty massive 1500 *2000, is there a efficient way to convert to .net

Also this pythonnet package has helped me greatly, thanks for all your efforts in developing and maintaining it!

@den-run-ai
Copy link
Contributor

@user015 see suggestions here: #514

@dmitriyse
Copy link
Contributor

In CoreCLR 2.1 we have Span API so I think is could be many times faster approach.

@den-run-ai
Copy link
Contributor

@dmitriyse that's what I was thinking too, but the suggestion i linked above was good enough for me.

@user015
Copy link
Author

user015 commented Mar 28, 2018

I tried a couple of the approaches in that link and they didn't work for me. I am guessing I have a ndarray(2D) vs a single D array is the issue, those approaches might work for a single d numpy array. I haven't tried the pure python solution at the very end, but either way I think I can get around this. Thanks!

Edit:- The python code from Robert McLeod in the above link worked great, Thanks!

@Kemsekov
Copy link

Kemsekov commented Jan 4, 2024

I've added answer alongside with Robert McLeod for c# side

#514 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants