-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Correct type inference for UInt64Index during access #29420
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
Changes from 5 commits
606b71d
7b0eef4
2b537c6
82cdc80
d1818dd
3e370b2
1722116
500e73c
813ed20
78db1e8
a5d20d9
03b91b1
aac01ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1187,3 +1187,39 @@ def test_range_float_union_dtype(): | |
|
||
result = other.union(index) | ||
tm.assert_index_equal(result, expected) | ||
|
||
|
||
def test_uint64_keys_in_list(): | ||
# https://github.com/pandas-dev/pandas/issues/28023 | ||
bug = pd.Series( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could both these test functions be combined into 1 func? Seem very similar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are indeed similar. I'll wait for a few more comments to decide on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea pls do we prefer parametized tests as much as possible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revisiting the issues, I realized one of the tests would be redundant and removed that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How come? - it seems that test case was exactly covering issue #28023 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just use https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.testing.assert_index_equal.html Hope that helps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #28023 reports a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About the test function... Now that I'm rooting for a single test, I'll leave it as |
||
[0, 1, 2, 3, 4], | ||
index=[ | ||
7606741985629028552, | ||
17876870360202815256, | ||
13106359306506049338, | ||
8991270399732411471, | ||
8991270399732411471, | ||
], | ||
) | ||
|
||
tm.assert_equal( | ||
bug.loc[[7606741985629028552, 17876870360202815256]], bug.iloc[[0, 1]] | ||
) | ||
|
||
|
||
def test_uint_index_not_converted_to_float64(): | ||
# https://github.com/pandas-dev/pandas/issues/28279 | ||
bug = pd.Series( | ||
oguzhanogreden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[0, 1, 2, 3, 4], | ||
index=[ | ||
7606741985629028552, | ||
17876870360202815256, | ||
13106359306506049338, | ||
8991270399732411471, | ||
8991270399732411472, | ||
], | ||
) | ||
|
||
assert isinstance( | ||
bug.loc[[7606741985629028552, 17876870360202815256]].index, UInt64Index | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explicitly construct the expected index and use result = s.loc[[7606741985629028552, 17876870360202815256]].index
expected = UInt64Index([7606741985629028552, 17876870360202815256])
tm.assert_index_equal(result, expected) I'd rather not do a simple In [2]: idx = pd.UInt64Index([2**53, 2**53 + 1])
In [3]: idx
Out[3]: UInt64Index([9007199254740992, 9007199254740993], dtype='uint64')
In [4]: pd.UInt64Index(pd.Float64Index(idx))
Out[4]: UInt64Index([9007199254740992, 9007199254740992], dtype='uint64') |
Uh oh!
There was an error while loading. Please reload this page.