Issue in binding of Piecewise.curve_at_index
See https://gepgitlab.laas.fr/pfernbac/curves/-/jobs/60305 with new python test-case highlighting the issue. (line https://gepgitlab.laas.fr/pfernbac/curves/blob/9c579a27de430d77541a2d9d0d994cfc63e5c4fc/python/test/test.py#L422 fail).
In the current implementation, piecewise::curve_at_index
return a shared_pointer<curve_abc>
, then it can be binded directly with boost::python because the shared_pointers for each python class are defined.
This implementation work only if the curve returned by piecewise::curve_at_index
have been created in python before the call of the method, as it was the case in all the previous unit-test (eg in https://gepgitlab.laas.fr/pfernbac/curves/blob/9c579a27de430d77541a2d9d0d994cfc63e5c4fc/python/test/test.py#L367).
In the case where the curve have been created in C++, when the shared_pointer is returned and wrapped by boost::python, it is wrapped in the parent abstract class (curve_abc
) instead of the real class. Which lead to the error in the failed job linked above.
This issue may be solved by returning a raw pointer in C++ instead of a shared pointer and then bind the method with boost::python::return_internal_reference
. But I did not test this deeply and I do not know if it's the best way to solve this.