Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork320
Return numpy array from python to Lazarus#488
-
Hi, I've recently started playing around with P4D in Lazarus/FPC. I'm trying to read a numpy array created in python back in to FPC. The python code which I have in SynEdit1:
My attempt at the FPC code below to extract py_array is based on FPC Demo35:
However, when I run this, I only end up with a single, random number in ListBox1. Any suggestions on how to resolve this would be greatly appreciated! |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
If you run this code in PyScripter importnumpyasnppy_array=np.zeros(10)foriinrange (10):py_array[i]=iprint(py_array) The output is:
Notice that the values are floating point and you try to read them as Integers. I think if you change your code to: importnumpyasnppy_array=np.zeros(10,dtype=np.int32)foriinrange (10):py_array[i]=i or simpler: importnumpyasnppy_array=np.array(range(10)) it should work. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1