-
Notifications
You must be signed in to change notification settings - Fork 908
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 bug when iloc
slice terminates at before-the-zero position
#7277
Conversation
@isVoid can you retarget this to 0.18? This is a nice bugfix with minimal changes that would be good to get in. |
[Updated] Moving |
@@ -831,6 +833,66 @@ def __sizeof__(self): | |||
index = self._index.__sizeof__() | |||
return columns + index | |||
|
|||
def _slice(self: T, arg: slice) -> T: |
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.
Does this not get used underneath Series.iloc[slice(...)]
as well?
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.
Series.iloc
seems to depend on ColumnBase.__getitem__
, which later calls ColumnBase.slice
.
cudf/python/cudf/cudf/core/indexing.py
Line 79 in 3ecde9d
data = self._sr._column[arg] |
I also noticed the following:
>>> s = cudf.Series([1,2,3,4,5])
>>> s.iloc[4:-1:-1]
Series([], dtype: int64)
which is likely the same issue, investigating.
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.
It's the same issue in ColumnBase.slice
.
cudf/python/cudf/cudf/core/column/column.py
Lines 609 to 610 in b8cb8c7
if stop < 0: | |
stop = stop + len(self) |
Submitted a quick fix. Although I think the best fix here is to consolidate Series.iloc
and DataFrame.iloc
to share the common code path under Frame._slice
.
Additional changes based on Series.slice
rerun tests |
@gpucibot merge |
Codecov Report
@@ Coverage Diff @@
## branch-0.18 #7277 +/- ##
===============================================
+ Coverage 82.09% 82.19% +0.10%
===============================================
Files 97 100 +3
Lines 16474 16954 +480
===============================================
+ Hits 13524 13936 +412
- Misses 2950 3018 +68
Continue to review full report at Codecov.
|
rerun tests |
@isVoid There seem to be some conflicts, could you resolve them? |
Closes #7246
This PR fixes a bug in
Dataframe.iloc
. When the slice provided toiloc
, is decrementing and also terminates atbefore-the-zero
position, such asslice(2, -1, -1)
orslice(4, None, -1)
, the terminal position still gets wrapped around.Frame._slice
is moved toDataFrame._slice
to resolve typing issue.