1

I'm running cpp code in python using cppyy module. At some point I need to pass array to the CPP function. When I pass numpy array I get following error.


ValueError                                Traceback (most recent call last)
<ipython-input-15-331df36ad536> in <module>
----> 1 getPeakall(2, input_array, len(input_array))

ValueError: PeaksData ::getPeakall(int argc, double* argv, int len) =>
    ValueError: nullptr result where temporary expected

I guess I need to need to convert ndarray to CPP vector array or pointer array and then pass as an input to CPP function. Pleas help!!

Jason
  • 36,170
  • 5
  • 26
  • 60
Aba
  • 11
  • 1
  • can you post your code? –  Feb 03 '22 at 12:46
  • Code line: cppyy.gbl.getPeakall(2, input_array, len(input_array)) – Aba Feb 03 '22 at 15:41
  • What is the type of `input_array` and is it flat/contiguous? You *can* force passing non-contiguous numpy arrays through a `double*`, but as a rule, numpy will not allow it unless explicitly told (through casting) that you accept the consequences. – Wim Lavrijsen Feb 03 '22 at 17:55

0 Answers0