-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: GH12034 RangeIndex.__floordiv__ returns RangeIndex if possible #12070
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
Conversation
Not sure if I should always return |
@kawochen I had the same thoughts for |
pls add this issue number to the whatsnew note as well. |
0224746
to
3e0f331
Compare
(RangeIndex(-100, -200, 3), 2, RangeIndex())] | ||
for idx, div, expected in cases_equiv: | ||
result = idx // div | ||
tm.assert_index_equal(result, expected, exact=False) |
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.
shouldn't you just have exact=True
here?
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.
For len(self) == 1
and len(self) == 0
the equivalent classes are particularly large, and it doesn't matter which representatives to return. e.g. you could always return RangeIndex()
for len(self) == 0
or leave _start
unchanged. And since when len(self) == 1
, step // div
could be 0, I couldn't treat all cases the same. The choice of step
and stop
is arbitrary so I had exact=False
.
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.
oh I just looked at assert_index_equal
, so it defers to Index.equals
-- I will change it to exact=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.
the exact
defaults to equiv
which means Int64Index/RangeIndex
can be equivalent. exact=True
mean they must be exactly the same
ping when green |
3e0f331
to
d6c3528
Compare
d6c3528
to
7106263
Compare
updated |
merged via 8e29361 thanks! |
xref #12034