Repository navigation
Conversation
make_index maps each dimension i of the underlying expression to its
slice k, then to the position of that slice in the view index:
k minus the number of integral slices before it. It counted the
integral slices before i instead of before k. The two differ when a
newaxis comes before an integral slice, so the wrong index was read:
xt::xarray<int> a = {{0, 1, 2}, {3, 4, 5}};
auto v = xt::view(a, xt::newaxis(), 1, xt::all());
v[{0, 2}]; // returned 3 instead of 5
operator() already used the slice position. element(), and the
operator[] and at-style accesses built on it, now do too.
Contributor
Merging this PR will not alter performance1 warning
Comparing |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description
xview::elementreturned the wrong value when a newaxis comes before an integral slice:make_indexfinds the slicekof each underlying dimensioni, then the position of that slice in the view index:kminus the number of integral slices before it. It counted the integral slices beforeiinstead ofk.operator()already did it right.xview.element_newaxis_before_integralfails on master and passes with the fix. I found this while writing a differential test for thexview_stepperfix, which usedelement()as its reference.