-
Notifications
You must be signed in to change notification settings - Fork 915
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
Add support for additional metaclasses of proxies and use for ExcelWriter #15399
Add support for additional metaclasses of proxies and use for ExcelWriter #15399
Conversation
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.
Looks good. Might be good to add a unit test that an isinstance
check on this object with os.PathLike
works
I uncovered another strange thing while writing a test here. Given this script
Without the changes in this PR, I see the following behavior if I run that test inside the repo:
On the other hand, if I run from outside the repo I see this
Note that when run outside the repo the class shows up differently. I don't know why that is, but it makes testing from inside the repo difficult because the issue is masked. I'll dig a little more next week, this is as far as I got today. @shwina or @wence- if this makes quick sense to you feel free to jump in. |
I need to come back to this and investigate further. @galipremsagar or @wence- if the above result makes sense to you let me know, but no need to spend much time investigating if it doesn't. I'll come back to this when I have a bit of time free. |
fd9616f
to
b4719b7
Compare
OK @mroeschke I've added a test here. The issue above is not related to this PR, and the behavior can be observed even without it. The issue is that the pandas ExcelWriter overrides I think fixing this issue is out of scope for this PR, but it's something we may need to investigate further. In pandas >=2.0, with the new index class hierarchy is it still possible to instantiate an index with the base index constructor that doesn't isn't of type Index now that the numerical and string index types are gone? For example, categorical indexes I believe must be constructed with the pd.CategoricalIndex constructor now, right? If there are any exceptions, I would expect them to exhibit the same behavior. |
We have a similar problem for |
I re-ran the CI to see the latest diff of the tests passing/failing. |
It claims to be a big increase of 1.38% :D do you believe it? I don't. |
It's most likely because the nightly run that happened yesterday doesn't have all the changes of this branch. But since there is no decrease, we can say this is a safe change 👍 |
/merge |
Description
The ExcelWriter supports the abstract os.PathLike interface, but we would also like that support to be reflected in the class's MRO. Doing so is slightly complicated because os.PathLike is an ABC, and as such has a different metaclass. Therefore, in order to add os.PathLike as a base class, we must also generate a suitable combined metaclass for our ExcelWriter wrapper.
This change ensures the
isinstance(pd.ExcelWriter(...), os.PathLike)
returnsTrue
when using cudf.pandas.Checklist