-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Add base test for ExtensionArray.astype and copy #28488
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
Comments
I'm assuming we do want this property. It's what NumPy does
pandas/pandas/core/arrays/integer.py Line 518 in 5a227a4
self.dtype exactly matches dtype . In which case we just return self when copy=False .
We'll also want to update the docs in ExtensionArray.astype that this should return |
Hi! I'd like to work on this issue. |
Thanks! Let us know if you need help getting started. |
I would like to work on this issue, can you help me where to start |
I think @jimmybeckett may already be working on it. |
Hi, can I work on this issue? |
@IsabellaRO that'd be great. I don't think anyone has submitted a pull request for it yet. |
Given that there hasn't been any activity on this issue for a few months, I figured it would be okay to jump on this issue. I looked into the first failed test, which fails on the BooleanArray. I want to walk through my understanding of the problem and solution, @TomAugspurger, to make sure I'm getting this right. I'm going to be a little verbose for clarity's sake. The first test that fails:
So I dropped in with the --pdb flag to see what's happening.
Turns out result and data are different objects, according to id(). That must be happening when result is created from data.astype, so I drop into pandas.core.array.boolean.BooleanArray.astype and add a breakpoint...
And test equality of the parts This points to that BooleanArray constructor call as the culprit. I think the solution is to check whether copy is False, and if so, then simply return self instead of calling that constructor. e.g.
The changes above make the test pass. |
@tomaszps that looks right, thanks. |
I'm a little confused about a detail- pandas.core.arrays.base.ExtensionArray.astype always coerces to and returns a numpy array. This is not the desired behavior, correct? That seems inconsistent with the way other subclasses of extensionarray act, where the method is overridden (e.g. Integer, Boolean extensionarrays). |
take |
I'm digging further, I'll dump the rest of my questions/notes here until there's a response. That solution or some variant worked for all of the tests up to All the others failed for the reason mentioned above, and I have fixes hacked in. The results are up in my branch. I'd need to go through and clean up the commit for merging to make the style consistent between the fixes. edit: Sorry for not following standards in my PR. I figured I would get everything down and then do an interactive rebase and force push it or push it to a new branch. |
@TomAugspurger I looked in the contribution docs but didn't see- is there a standard way to solicit feedback on an issue? (If I'm a new person and I have questions because I'm unfamiliar. @'ing you repeatedly seemed wrong, but I don't know better. |
It's easiest to make a PR and then we can comment on the diff.
…On Thu, Jul 2, 2020 at 6:31 PM Tomasz Sakrejda ***@***.***> wrote:
I'm digging further, I'll dump the rest of my questions/notes here until
there's a response.
That solution or some variant worked for all of the tests up to
pandas/tests/extension/test_string.py::TestCasting::test_astype_own_type[True]
FAILED [ 87%]
which seems to be failing because *eq* is not implemented for the
StringArray class.
All the others failed for the reason mentioned above, and I have fixes
hacked in. The results are up in the PR. I'd need to go through and clean
up the commit for merging to make the style consistent between the fixes.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#28488 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKAOIXPHSUWFS5DAWBX2P3RZUKFZANCNFSM4IXU4L7Q>
.
|
Uh oh!
There was an error while loading. Please reload this page.
We should be able to test astype to our own type
A few tests fail this. Would welcome investigation.
$ pytest pandas/tests/extension/ -k test_astype_own_type -v --tb=line
The text was updated successfully, but these errors were encountered: