xtensor-python
xtensor-python copied to clipboard
dtype gets implicitly converted, and buffer is copied
When we have a function taking a pyarray
We should think about emitting a warning in this case, or make the warning user modifiable. Or at least clearly document it.
Actually in pybind11 there is a compile-time option like so:
void f(py::array_t<double, py::array::c_style | py::array::forcecast> array);
To signify if that array should be casted or not. Maybe we could use that, or something similar?
Is this a similar issue to the following:
Suppose we have a function
void foo(xt::pytensor<int, 1>& arg)
that changes arg
in place. Then currently the call to the function with the wrong numpy.dtype
does not result in any error, but does not change the desired object either because of an implicit type conversion. The questions are:
- What can be done to switch off the implicit conversion in specific cases?
- How can a function be overloaded for all relevant NumPy types?
cc @JohanMabille