-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: .isin on datetimelike indexes do not validate input of level parameter #26677
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9ae69e3
BUG: .isin on datetimelike indexes do validate input of level parameter
simonjayhawkins 05db5f7
resolve merge conflict
simonjayhawkins 24bbb24
remove unused code from conftest.py
simonjayhawkins e37fe59
Merge remote-tracking branch 'upstream/master' into isin-datetimelike
simonjayhawkins 1c88839
sort indexes to fix mutlicore pytest failures (and isort)
simonjayhawkins 2d201b0
fix trailing whitespace in rst file
simonjayhawkins 4bcdf63
simplify expression
simonjayhawkins 675864c
Merge remote-tracking branch 'upstream/master' into isin-datetimelike
simonjayhawkins d8b2c37
remove unnecessary complexity
simonjayhawkins 84e8cc4
fix typo
simonjayhawkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
import pytest | ||
|
||
import pandas as pd | ||
from pandas.core.indexes.api import Index, MultiIndex | ||
from pandas.core.indexes.api import Index, MultiIndex, RangeIndex, PeriodIndex | ||
import pandas.util.testing as tm | ||
|
||
indices_list = [tm.makeUnicodeIndex(100), | ||
|
@@ -47,3 +47,37 @@ def zero(request): | |
# For testing division by (or of) zero for Index with length 5, this | ||
# gives several scalar-zeros and length-5 vector-zeros | ||
return request.param | ||
|
||
|
||
def _get_subclasses(cls): | ||
for subclass in cls.__subclasses__(): | ||
yield from _get_subclasses(subclass) | ||
yield subclass | ||
|
||
|
||
all_indexes = [index for index in ([Index] + list(set(_get_subclasses(Index)))) | ||
if getattr(pd, index.__name__, None) is not None] | ||
|
||
|
||
@pytest.fixture(params=all_indexes) | ||
def all_index_types(request): | ||
""" | ||
A Fixture for all indexes types. Index and subclasses in pandas namespace. | ||
""" | ||
return request.param | ||
|
||
|
||
@pytest.fixture | ||
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. shouldn't this just work off of the indices_list? why creating extra machinery here? |
||
def all_index_empty(all_index_types): | ||
""" | ||
A Fixture for empty instances of all indexes types in pandas namespace. | ||
""" | ||
cls = all_index_types | ||
if issubclass(cls, RangeIndex): | ||
return cls(0, name='foo') | ||
elif issubclass(cls, MultiIndex): | ||
return cls.from_arrays([[], []], names=['foo', 'bar']) | ||
elif issubclass(cls, PeriodIndex): | ||
return cls([], freq='M', name='foo') | ||
else: | ||
return cls([], name='foo') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What is the name check for?
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.
Can just simplify to
if getattr(pd, index.__name__, 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.
missed that. thanks.