[cctbxbb] boost python exports

David Waterman dgwaterman at gmail.com
Wed Mar 2 06:27:54 PST 2022


Hi folks,

I'm trying to create a boost python class that works with either vec3 or
mat3 arrays (and I only need those two types). I made a templated class and
then exported it twice with different names, for the vec3 and mat3
versions. For example, for mat3:

    class_<ReconstituteDerivatives< mat3<double> >
>("ReconstituteDerivativesMat3", no_init)
      .def("get_data", &ReconstituteDerivatives< mat3<double> >::get_data)
      .def("get_indices", &ReconstituteDerivatives< std::size_t
>::get_indices);

I can create one of these objects from Python

>>> foo
<dials_refinement_helpers_ext.ReconstituteDerivativesMat3 object at
0x7f3ffa421ac0>

but the accessors are not exported properly:

>>> foo.get_data()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: No to_python (by-value) converter found for C++ type:
scitbx::af::shared<scitbx::mat3<double> >

I expected a scitbx_array_family_flex_ext.mat3_double here

>>> foo.get_indices()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
    ReconstituteDerivativesMat3.get_indices(ReconstituteDerivativesMat3)
did not match C++ signature:
    get_indices(dials::refinement::ReconstituteDerivatives<unsigned long>
{lvalue})

and I expected a scitbx_array_family_flex_ext.size_t here.

Is it likely there is something simple I am missing, like a #include? I do
include flex_wrapper.h. Or perhaps I am just doing something wrong with
templated classes and boost python. Looking at other code isn't helping to
reveal the mysteries to me yet.

Cheers
-- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://phenix-online.org/pipermail/cctbxbb/attachments/20220302/283d10bc/attachment.htm>


More information about the cctbxbb mailing list