Skip to content
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

REF: make _cast_pointwise_result an EA method #59895

Open
jbrockmendel opened this issue Sep 25, 2024 · 1 comment
Open

REF: make _cast_pointwise_result an EA method #59895

jbrockmendel opened this issue Sep 25, 2024 · 1 comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Refactor Internal refactoring of code

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Sep 25, 2024

In the extension tests.extension.base.ops.BaseOpsUtil we have a _cast_pointwise_result method that is used to patch the result of Series.combine to do appropriate dtype inference so that we have e.g.

expected = series + other
middle = series.combine(other, operator.add)
result = self._cast_pointwise_result(middle)
tm.assert_series_equal(result, expected)

(There is also a test_combine_add method which does not currently use _cast_pointwise_result but could. Also test_combine_le looks like we implemented an entirely separate pattern for customizing dtype inference in that test. I'll look into seeing if these can re-use the _cast_pointwise_result pattern.)

This cast_pointwise_result should just be an EA method. ATM we override it in the arrow, masked, and string tests (I suspect that we should be overriding it in the sparse tests but it looks like we skip a bunch of them instead).

This will effectively replace _from_scalars, which was a mis-feature. It will also let us de-kludge places where we use maybe_cast_pointwise_result and generally be more robust.

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 25, 2024
@jbrockmendel jbrockmendel changed the title REF: make _cast_poitnwise_result an EA method REF: make _cast_pointwise_result an EA method Sep 25, 2024
@jbrockmendel
Copy link
Member Author

It also looks a lot like test_combine_add+test_combine_le are made redundant by more general tests in BaseComparisonOpsTests and BaseArithmeticOpsTests

@rhshadrach rhshadrach added Refactor Internal refactoring of code ExtensionArray Extending pandas with custom dtypes or arrays. and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Refactor Internal refactoring of code
Projects
None yet
Development

No branches or pull requests

2 participants