xtensor-stack / xtensor-python

Python bindings for xtensor
BSD 3-Clause "New" or "Revised" License
348 stars 58 forks source link

Add support for xtensor_fixed #163

Open PerretB opened 6 years ago

PerretB commented 6 years ago

Hi,

currently xtensor python brings seamless integration of xarray and xtensor types with numpy. However xtensor_fixed type is not supported. Hence the following definitions work (with m an instance of pybind11::module):

m.def("test_xarray", [](){return xt::xarray<int>{1,2};});
m.def("test_xtensor", [](){return xt::xtensor<int, 1>{1,2};});

while this one fails

m.def("test_xtensor_fixed", [](){return xt::xtensor_fixed <int, xt::xshape<2>>{1,2};});

at runtime. When trying to call the method from python, the following error is reported:

TypeError: Unable to convert function return value to a Python type! The signature was
() -> xt::xfixed_container<int, xt::fixed_shape<2ul>, (xt::layout_type)1, xt::xtensor_expression_tag>

Would it be possible to add seamless integration with xtensor_fixed ?

robertodr commented 5 years ago

This would be a very welcome addition!

TheButlah commented 4 years ago

This would be a really nice thing to have! xtensor_fixed is a fundamental datatype and the absence of this feature is going to cause me to have to rewrite a lot of code that I expected to easily use from python...