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_
("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
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
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
Ah yes, I have to remember to actually import flex in python for the
get_data() accessor to work.
foo.get_indices() is a different issue. I should be able to copy-and-paste
whatever I need from somewhere else a scitbx::af::shared< std::size_t > is
returned.
Cheers
-- David
On Wed, 2 Mar 2022 at 14:27, David Waterman
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_
("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
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
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
Oops, I see the problem there too ;-)
So, sorry for the noise, I got my toy example working now
-- David
On Wed, 2 Mar 2022 at 16:43, David Waterman
Ah yes, I have to remember to actually import flex in python for the get_data() accessor to work.
foo.get_indices() is a different issue. I should be able to copy-and-paste whatever I need from somewhere else a scitbx::af::shared< std::size_t > is returned.
Cheers -- David
On Wed, 2 Mar 2022 at 14:27, David Waterman
wrote: 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_
("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
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
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
participants (1)
-
David Waterman