-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
API: change datetimelike Index to raise IndexError instead ValueError #18386
API: change datetimelike Index to raise IndexError instead ValueError #18386
Conversation
pandas/tests/indexes/test_base.py
Outdated
if indices.size != 100: | ||
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need this at all, just check for the error
Codecov Report
@@ Coverage Diff @@
## master #18386 +/- ##
==========================================
- Coverage 91.36% 91.34% -0.02%
==========================================
Files 164 164
Lines 49718 49718
==========================================
- Hits 45426 45417 -9
- Misses 4292 4301 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18386 +/- ##
==========================================
+ Coverage 91.32% 91.41% +0.08%
==========================================
Files 164 157 -7
Lines 49802 51378 +1576
==========================================
+ Hits 45484 46965 +1481
- Misses 4318 4413 +95
Continue to review full report at Codecov.
|
pandas/tests/indexes/test_base.py
Outdated
|
||
assert exp == arr[5] | ||
if indices.size != 100: |
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.
why do you have this?
pandas/tests/indexes/test_base.py
Outdated
if indices.size != 100: | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need this at all, just check for the error
@@ -591,12 +591,19 @@ def test_empty_fancy(self): | |||
# Index. | |||
pytest.raises(IndexError, idx.__getitem__, empty_farr) | |||
|
|||
def test_getitem(self): |
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.
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.
add a note in whatsnew indexing bug fixes (0.22)
thanks @jorisvandenbossche |
I noticed this in the plotting PR that DatetimeIndex et al behave a bit strange on an invalid index:
I think this should be consistent IndexError ?