xtensor-stack / xtensor-python

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

Enable load cast `xt::xtensor<...>` #264

Open tdegeus opened 3 years ago

tdegeus commented 3 years ago

Sometimes my API simply does not permit easily to template, or I just want to wrap quick and dirty, or on needs to work around a bug. For these case I still want to be able to wrap

void foo(const xt::xtensor<double, 1>& a);

Currently this is explicitly prohibited in xtensor-python https://github.com/xtensor-stack/xtensor-python/blob/9aa58f8a5316548bb382e6f14aa557c2c96d9399/include/xtensor-python/xtensor_type_caster_base.hpp#L77-L80

I find this too restrictive, and I think that xtensor-python should have a way to do it, for instance by setting a flag or include a header. We should give the possibility to work around something, even if it comes at the cost of a copy.