You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Indexing in operator() wrong for xview with xt::newaxis()? #2228
I have a small problem with assigning to an xview that was created from an xtensor with xt::newaxis(). The code is given below, and also in a separate PR for review. I'm under the impression that the indexing is somehow incorrect. Here is the code sample:
xt::xtensor<uint8_t, 2> aTensor = xt::zeros<uint8_t>({4, 3});
auto aView = xt::view(aTensor, xt::newaxis(), xt::newaxis(), xt::newaxis(), xt::all(), xt::all());
uint8_t vIndex = 0;
// Counting only until (vRow < 3) here, otherwise we get an out-of-bounds exception:for (size_t vRow = 0; vRow < 3; ++vRow) {
for (size_t vCol = 0; vCol < 3; ++vCol) {
aView(size_t{0}, size_t{0}, size_t{0}, vRow, vCol) = vIndex;
EXPECT_EQ(aTensor(vRow, vCol), vIndex); ///< This finds the elements are *not* equal
++vIndex;
}
}
For what its worth, here is what I could see in the debugger:
in xt::xview in operator() everything seems correct and indexes are checked correctly.
then the view seems to call the operator() of the underlying memory holding container (in my case a 2D xtensor)
in this different-dimensional operator(), the indexes seem messed up. It looks like they would be in reverse order, or maybe some padding is missing or too much.
Activity
zYeoman commentedon Nov 26, 2020
Similar issue here.
The pic is a
xt::xarray<uint16_t>auto&& patch = xt::view(pic, xt::range(i, i + tile_height), xt::range(j, j + tile_width));The follow code is correct.
But these code is wrong
emmenlau commentedon Nov 26, 2020
For what its worth, here is what I could see in the debugger:
operator()everything seems correct and indexes are checked correctly.operator()of the underlying memory holding container (in my case a 2D xtensor)operator(), the indexes seem messed up. It looks like they would be in reverse order, or maybe some padding is missing or too much.emmenlau commentedon Jan 22, 2021
This would be nice to be fixed, esp. because its a "silent" error where the code actually seems to work but gives wrong results.
emmenlau commentedon Mar 17, 2023
Kindly pinging this issue...
emmenlau commentedon Jun 4, 2024
Kindly pinging this issue...
emmenlau commentedon Mar 31, 2025
Kindly pinging this issue, that seems to perform wrong indexing (could be a bad bug?)
Alex-PLACET commentedon May 4, 2026
Fixed in #2896