xtensor
xtensor copied to clipboard
Fixing some iterator issues
This merge request fixes some issues with iterators.
- [x]
xfunctor_view::crbegin
was returning non const iterator - [x]
xiterator_adaptor::data
was returning iterator, not a pointer - [x]
xt::reshape_view().rbegin()
didn't compile
Fixing multidimensional index of end xiterator
- [x] multidimensional index of
xiterator
forend()
iterator would be always set toshape()
, which made*rbegin()
be out of bounds access. I changed the index ofend()
to beshape[i] - 1
for all dimensions, except the last one in row-major case, and except the first one in column-major case
xarray<int> a = { {{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 10, 11}},
{{12, 13, 14, 15},
{16, 17, 18, 19},
{20, 21, 22, 23}} };
auto view = dynamic_view(a, { 1, keep(0, 2), range(1, 4) });
// shape: {1, 2, 3}
// old version
view.end(); // index {1, 2, 3}
std::prev(view.end()); // index {1, 2, 2}
// out of bounds access
*view.rbegin(); // index {1, 2, 2}
// new version
view.end(); // index {0, 1, 3}
std::prev(view.end()); // index {0, 1, 2}
// correct access
*view.rbegin(); // index {0, 1, 2}
Sorry for missing this, I have been swamped with a lot of other tasks. There is an issue in this PR that I want to comment on since it is not trivial. I'll try to do it next week.
This pr is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days.
Hey, are there any updates on including this in xtensor?
Sorry for missing this, I have been swamped with a lot of other tasks. There is an issue in this PR that I want to comment on since it is not trivial. I'll try to do it next week.
Hey @JohanMabille , you said there are some issues with this PR, can you tell us a hint where to look?
@JohanMabille I updated the merge request, removed the changes to buffer adaptor's API. There is a failing 'pretty format json' pre-commit check, I'm not sure what does that mean and how to deal with that?
[... ] There is a failing 'pretty format json' pre-commit check, I'm not sure what does that mean and how to deal with that?
I think running pre-commit run --all-files
and push the changes should fix the issue. This failure is probably due to an update of pre-commit since your PR does not change anything regarding the notebooks.
Actually this also requires updating the config, let's merge this one and I'll fix the build on master directly.
Thanks!