-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fix failing tests with Pandas 1.3.0 (was: Add logic to deal with ABCIndexClass being renamed to ABCIndex) #218
Conversation
Okay, that didn't work. Will try something else. |
Fixed some bugs in |
Update: Most of the test failures seem to be due to a bug in Pandas 1.3.0. Due to some performance optimizations introduced in pandas-dev/pandas#40353, Pandas turns Code to reproduce: from pandas.api.extensions import ExtensionArray,ExtensionDtype
class MyExtensionDtype(ExtensionDtype):
"""Minimal extension dtype"""
def __init__(self):
pass
@property
def type(self):
return int
@property
def name(self) -> str:
return "MyExtensionDtype"
@classmethod
def construct_array_type(cls):
return MyExtensionArray()
class MyExtensionArray(ExtensionArray, ExtensionScalarOpsMixin):
"""Minimal extension array that logs calls to __getitem__()"""
@property
def dtype(self):
return MyExtensionDtype()
def copy(self):
return MyExtensionArray()
def __len__(self):
return 5
def __getitem__(self, key):
print(f"__getitem__ called with key '{key}'")
return 42
arr = MyExtensionArray()
df = pd.DataFrame({"a": arr})
_ = df.iloc[:3] which prints out:
It should print the following instead:
I'll put in a workaround tomorrow and file a bug with Pandas. |
Update:
|
Update: Fixed another minor bug. Now we are down to 49 failing tests. |
Update:
Now we're down to 2 failing tests. |
…th_frame_with_scalar()
All tests passing against Pandas 1.3.0 now. Merging this PR to unblock other PRs. |
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.
LGTM, just a minor suggestion
# ABCIndexClass changed to ABCIndex in Pandas 1.3 | ||
# noinspection PyUnresolvedReferences | ||
from pandas.core.dtypes.generic import ABCIndex | ||
ABCIndexClass = ABCIndex |
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 could do from pandas.core.dtypes.generic import ABCIndex as ABCIndexClass
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 should have thought of that. Will put in a follow-on PR with that edit.
Minor: Address review comments from #218
Pandas 1.3.x renamed its abstract base class for indexes from
ABCIndexClass
toABCIndex
, which is messing up some of our type checks. This PR adds some logic to work around that renaming. I'm using exceptions as control flow, which is a bit ugly, but the alternatives are also ugly.