-
Notifications
You must be signed in to change notification settings - Fork 25
Allow negative slices when indexing chunked data #170
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #170 +/- ##
==========================================
+ Coverage 76.83% 77.33% +0.49%
==========================================
Files 15 15
Lines 2936 2974 +38
Branches 467 477 +10
==========================================
+ Hits 2256 2300 +44
+ Misses 558 555 -3
+ Partials 122 119 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bnlawrence
left a comment
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.
This looks pretty straightforward I think, but I just have some minor comment comments to consider.
| def __init__(self): | ||
| super().__init__("only slices with step >= 1 are supported") | ||
|
|
||
| # And the rest of the code is the original file. |
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.
I guess this is no longer true
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 right. I think that negative step slices are OK in all cases, now ...
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.
So I would remove that comment (line 50), then I think this can be approved.
pyfive/indexing.py
Outdated
| elif index == Ellipsis: | ||
| raise ValueError( | ||
| "replace_negative_slices doesn't work when selection " | ||
| "contains Ellipsis. Consider running replace_ellipsis first" |
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.
What is "replace_ellipsis", would the user know about this, could it have a link?
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.
I've changed the message to
"replace_negative_slices(selection, shape) doesn't work "
"when selection contains Ellipsis. Consider doing "
"selection=pyfive.indexing.replace_ellipsis(selection, shape) "
"first"
pyfive/indexing.py
Outdated
| # dimensions might get dropped by integer indices) | ||
| dim = 0 | ||
|
|
||
| # Parse the indices |
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.
Maybe it's not so much parse the indices, as "parse and replace the indices"?
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.
Addressed: 082b00f
bnlawrence
left a comment
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.
I'm good to go once line 50 is gone (I would have done it myself .. .but)
I'm perfectly happy to do this, but was just wondering why, as that line has "always" been there ... |
Description
Currently (v1.0.1) negative slices, i.e. slices with a negative step, such as
[10:1:-1], are not allowed on chunked data. This breaks some downstream applications (e.g. cfdm and cf-python). This can be fixed.Closes #169
Before you get started
Checklist