-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lazy negative slice rewriting. #7586
Conversation
There was a bug in estimating the last index of the slice. Index a range object instead. Closes pydata#6560
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a nice trick, have to remember that one :)
Thanks @headtr1ck I made the test smaller. |
Could this potentially affect performance? |
Don't think so. I did add expliciit support for reversing a negative slice now. I think it's better?
|
6920b02
to
fb7ccc9
Compare
* 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)
There was a bug in estimating the last index of the slice.
Index a range object instead.