Skip to content

REF: move dispatch methods to WrappedCythonOp #41114

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 2 commits into from
Apr 26, 2021

Conversation

jbrockmendel
Copy link
Member

This gets us most of the way towards having everything in the correct class.

The sticking point that makes this not-a-slam-dunk is that a check is removed:

            if self._filter_empty_groups and not counts.all():
                assert result.ndim != 2
                result = result[counts > 0]

This condition never holds in the tests, and the assertion would fail if it ever did. I don't have a compelling reason to remove this check other than it being inconvenient to move it to WrappedCythonOp.

@jreback jreback added Groupby Refactor Internal refactoring of code labels Apr 23, 2021
@jreback jreback added this to the 1.3 milestone Apr 23, 2021
@@ -299,6 +299,270 @@ def get_result_dtype(self, dtype: DtypeObj) -> DtypeObj:
def uses_mask(self) -> bool:
return self.how in self._MASKED_CYTHON_FUNCTIONS

@final
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move WrappedCythonOps the class to a new module, maybe cython_ops.py? (can do it in this PR or pre-cursor)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at some point. naming-wise i actually think it makes sense for it to be in ops.py and everything else to be somewhere else, but im not sure where that would be (the relationship between Grouper vs BaseGrouper still confuses me)

if func_uses_mask:
func(
result,
return cy_op._ea_wrap_cython_operation(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make _ea_wrap_cython_operation and some of the other private methods called from an instance of WrappedCythonOp public? Are there are any rules of thumb we have for private/public methods for non-user facing classes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. i think before long _cython_operation itself will move, at which point it will become public

@jreback
Copy link
Contributor

jreback commented Apr 26, 2021

lgtm can you merge master

@jbrockmendel
Copy link
Member Author

Rebased + green

@jreback jreback merged commit d77b292 into pandas-dev:master Apr 26, 2021
@jbrockmendel jbrockmendel deleted the ref-gbop-wrapped branch April 26, 2021 18:16
yeshsurya pushed a commit to yeshsurya/pandas that referenced this pull request May 6, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Groupby Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants