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 am currently migrating from an older undefined pythonnet Version to 3.0.3 with an corresponding upgrade of python from 3.7.9 to 3.12.4.
We had some C# logic in place which executed python code and took the result of Tuple[nd.ndarray(dtype=int), nd.ndarray(dtype=float)] and converted it from dynamic to concrete types.
I am experiencing issues while converting the nd.ndarray(dtype=int) via (long[])result[0]
---- System.Exception : Cannot convert to System.Int64 array
-------- Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : Cannot convert type 'Python.Runtime.PyObject' to 'long[]'
The nd.ndarray(dtype=float) via (double[])result[1] works as a charme.
Same as when I both return as dtype=float and convert them to double.
My current workaround is iterating over the nd.ndarray(dtype=int) with the size of the result array by calling ToArrayByIteration()
This discussion was converted from issue #2407 on July 01, 2024 17:54.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Environment
Details
Describe what you were trying to get done.
I am currently migrating from an older undefined pythonnet Version to 3.0.3 with an corresponding upgrade of python from 3.7.9 to 3.12.4.
We had some C# logic in place which executed python code and took the result of Tuple[nd.ndarray(dtype=int), nd.ndarray(dtype=float)] and converted it from dynamic to concrete types.
I am experiencing issues while converting the nd.ndarray(dtype=int) via (long[])result[0]
The nd.ndarray(dtype=float) via (double[])result[1] works as a charme.
Same as when I both return as dtype=float and convert them to double.
My current workaround is iterating over the nd.ndarray(dtype=int) with the size of the result array by calling ToArrayByIteration()
Am I missing something?
Minimal, Complete, and Verifiable example
this will help us understand the issue.
Problematic here is converting "indices" from dtype=int to long in C#. The datatype of the result in C# in Debug view seems to be Int64.
Returning dtype=float is not intended but works with the same conversion to double.
I left out initialising pythonengine and loading the module in this case.
Beta Was this translation helpful? Give feedback.
All reactions