-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
API: change datetimelike Index to raise IndexError instead ValueError #18386
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 1 commit
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 |
---|---|---|
|
@@ -591,12 +591,19 @@ def test_empty_fancy(self): | |
# Index. | ||
pytest.raises(IndexError, idx.__getitem__, empty_farr) | ||
|
||
def test_getitem(self): | ||
arr = np.array(self.dateIndex) | ||
exp = self.dateIndex[5] | ||
exp = _to_m8(exp) | ||
def test_getitem(self, indices): | ||
|
||
assert exp == arr[5] | ||
if indices.size != 100: | ||
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. why do you have this? |
||
return | ||
|
||
exp = getattr(indices, '_box_func', lambda x: x)(indices._values[0]) | ||
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. This is a bit too much 'internal-details-relying' for a test, but I didn't directly know a way to write it generic for all types of index instead (or maybe we just shouldn't try, and keep it only testing the errors) 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. you don't need this at all, just check for the error |
||
assert indices[0] == exp | ||
|
||
with pytest.raises(IndexError): | ||
indices[101] | ||
|
||
with pytest.raises(IndexError): | ||
indices['no_int'] | ||
|
||
def test_intersection(self): | ||
first = self.strIndex[:20] | ||
|
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 original test is pretty useless, so no need to keep its function (and this is tested else in many places as well)
all of the indexes have a
test_indexing.py
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.
just rename the test to
test_getitem_error
. if you want you can split this out into a new file,test_indexing.py
in this dir.