Fix lazy negative slice rewriting.#7586
Merged
dcherian merged 9 commits intopydata:mainfrom Mar 27, 2023
Merged
Conversation
There was a bug in estimating the last index of the slice. Index a range object instead. Closes pydata#6560
dcherian
commented
Mar 5, 2023
3 tasks
headtr1ck
approved these changes
Mar 13, 2023
| stop = start + int((stop - start - 1) / step) * step + 1 | ||
| start, stop = stop + 1, start + 1 | ||
| return slice(start, stop, -step), slice(None, None, -1) | ||
| exact_stop = range(start, stop, step)[-1] |
Collaborator
There was a problem hiding this comment.
That's a nice trick, have to remember that one :)
Contributor
Author
|
Thanks @headtr1ck I made the test smaller. |
Collaborator
|
Could this potentially affect performance? |
Contributor
Author
|
Don't think so. I did add expliciit support for reversing a negative slice now. I think it's better? |
6920b02 to
fb7ccc9
Compare
dcherian
added a commit
to kmsquire/xarray
that referenced
this pull request
Mar 29, 2023
* upstream/main: Save groupby codes after factorizing, pass to flox (pydata#7206) [skip-ci] Add compute to groupby benchmarks (pydata#7690) Delete built-in cfgrib backend (pydata#7670) Added a pronunciation guide to the word Xarray in the README.MD fil… (pydata#7677) boundarynorm fix (pydata#7553) Fix lazy negative slice rewriting. (pydata#7586) [pre-commit.ci] pre-commit autoupdate (pydata#7687) Adjust sidebar font colors (pydata#7674) Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.3 (pydata#7682) Raise PermissionError when insufficient permissions (pydata#7629)
4 tasks
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.
There was a bug in estimating the last index of the slice.
Index a range object instead.