You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to import some data from a np.Array() and got some error at conversation of np.dtype = int32 to Int32 in csharp and got an error. After this I debugged it and found a way how it works. I cloned the repo and edited the following line in Python.Runtime's Converter.cs:
nintnum= Runtime.PyLong_AsSignedSize_t(value);
to
long?num= Runtime.PyLong_AsLongLong(value);
After this I wrote a test for all numpy int datatypes:
I encountered, that it fails in all cases, and replaced all affected lines in the switch case of the ToPrimitive() function and casted the type accordingly.
This worked well, except for the UInt64[].
The text was updated successfully, but these errors were encountered:
Where can I see the message from python side? - Is this to find in Python.Runtime Exceptions Class?
I am getting this error in the debugger:
System.InvalidCastException: cannot convert object to target type ---> Python.Runtime.PythonException: an integer is required
But there are also other ways to get the array into your memory after this. For example Buffer.BlockCopy.
Main thing is, the data is contiguous. The method is much faster, than converting the array as it is not converting every value as individual.
filmor
changed the title
conversation from np.dtype int to .net int fails
Conversion from np.dtype int to .NET int fails
Oct 5, 2023
Environment
Details
to
After this I wrote a test for all numpy int datatypes:
I encountered, that it fails in all cases, and replaced all affected lines in the switch case of the ToPrimitive() function and casted the type accordingly.
This worked well, except for the UInt64[].
The text was updated successfully, but these errors were encountered: