Closed ThibHlln closed 2 years ago
That sounds like a bug. Thanks for reporting.
Hi,
Does the following work?
py::array<double> res = arr1 - arr2;
std::cout << res << std::endl;
Hi,
Sorry, my example was misleading: this is when the Python interface is used that the problem occurs as I tried to demonstrate in your existing testing suite with: https://github.com/ThibHlln/xtensor-python/blob/broadcasting-problem/test_python/main.cpp#L114-L132 https://github.com/ThibHlln/xtensor-python/blob/broadcasting-problem/test_python/test_pyarray.py#L66-L108
If the pyarrays are defined directly in C++, the broadcasting works. This is when working with pyarrays defined via the Python bindings that the problem occurs (observable both in the returned numpy array and if I do a std::cout << arr1 - arr2 << std::endl;
in C++).
I can reproduce the problem, I am investigating.
Thank you! This works perfectly now.
By the way, in https://github.com/xtensor-stack/xtensor-python/blob/6a286681c48c35d3df342f291938f4825b20c0a3/test_python/test_pyarray.py, perhaps you did not mean to comment out all the other tests?
Hi there,
It seems that there may be some broadcasting problems with
xt::pyarray
on basic operations withoperator+
,operator-
,operator*
, andoperator/
.For example, with
operator-
:returns
For simplicity, I have added some tests to your existing test suite in a fork of mine, so that you can try to reproduce the problem yourself. See: https://github.com/ThibHlln/xtensor-python/blob/broadcasting-problem/test_python/main.cpp#L114-L132 https://github.com/ThibHlln/xtensor-python/blob/broadcasting-problem/test_python/test_pyarray.py#L66-L108
All 4 tests fail for me.
Could you tell me if these tests pass for you please? And if so, any idea what might be wrong here?
Thank you for your help, Thibault
Note: I am building/running this on Windows 10, version 1803 with
pybind11==2.9.2
,numpy==1.22.3
,xtensor==0.24.1
,xtl==0.7.4
and usingxtensor-python
from the master branch.EDIT If this helps, it works fine if I use
xt::pytensor<double, 2>
in place ofxt::pyarray<double>
.