xtensor-stack / xtensor-python

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

Casters for strided_views, array_adaptor, and tensor_adaptor #243

Closed PerretB closed 3 years ago

PerretB commented 3 years ago

This PR partly solves #130 by adding pybind11 type casters for strided_views and array/tensor_adapters.

As for xarrays and xtensors, those objects are casted to ndarray and do not use any proxy object (such as pyarray or pytensor): I did a bit of refactoring to put all those casters in a dedicated file.

Memory management becomes of course trickier with such objects.  I have the impression that what is done in xtensor_type_caster_base to handle return value policies is generic enough to fit these cases but I am not totally sure. I tried to demonstrate critical cases in the test file (cpp main). The tests validating the correctness of the memory management (keep alive policies) are perhaps not very interesting for regression detection has they focus on pybind11 mechanism rather than xtensor_python and could probably be removed.

PerretB commented 3 years ago

It seems that the CI configurations are outdated:

JohanMabille commented 3 years ago

I'm making a pass on the whole stack to fix all the CI issues (among them, migrating from travis to Azure), it takes time but eventually we'll get there.

JohanMabille commented 3 years ago

The tests validating the correctness of the memory management (keep alive policies) are perhaps not very interesting for regression detection has they focus on pybind11 mechanism rather than xtensor_python and could probably be removed.

I think we should keep them, this would help detecting any change or regression in pybind11. Even if pybind11 is well tested, having tests specific to our use case is a good thing.