Fix segmentation fault in machine test
Created by: femtobit
The reason for the segfault seems to have been that the Machine
instances only store references to the Hilbert instances.
Since these were created from Python and stores in the variable hi
,
they were deleted when hi
was assigned another Hilbert instance,
in the test code and the machines then contained dangling references.
The return value policy for Machine.get_hilbert
is py::return_value_policy::reference
, which I think is correct (and this policy should also be specified for Operator.get_hilbert
).
The part using Gradient
in one of the tests is still commented out because Gradient
does not seem to be exported right now (unless I missed something).