-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
implement Delegator class #17662
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
implement Delegator class #17662
Conversation
BTW the git diff is broken up in an unfortunate way. Is there a way to tell show it where it should start and stop the diff blocks? |
Codecov Report
@@ Coverage Diff @@
## master #17662 +/- ##
==========================================
- Coverage 91.26% 91.23% -0.04%
==========================================
Files 163 163
Lines 49806 49820 +14
==========================================
- Hits 45455 45451 -4
- Misses 4351 4369 +18
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17662 +/- ##
==========================================
- Coverage 91.26% 91.23% -0.04%
==========================================
Files 163 163
Lines 49806 49820 +14
==========================================
- Hits 45455 45451 -4
- Misses 4351 4369 +18
Continue to review full report at Codecov.
|
note really sure how this improves things. |
The motivation is very much based around clarity for newcomers. I had trouble figuring out Docstrings/exposition/tests aside, the only code-organization improvement here is removing an unnecessary level of nesting in the implementations of This is also a small step in the direction of implementing xarray's custom accessor api. |
this is not anymore clear IMHO. you can actually do this using proper descriptors, that would be a nice change. |
This is not a battle worth winning. Closing. |
This follows #17651 in breaking #17042 into smaller pieces. I expect one more piece after this, but will consider it a win if it ends here.
At the moment
PandasDelegate
defines_create_delegator_property
and_create_delegator_method
inside_add_delegate_accessors
(but namespace-wise do not need to). When first trying to figure out howstr
,cat
, anddt
worked, I found the levels of redirection confusing. This PRa) moves these dynamically-defined functions into staticmethods of a new
Delegator
class,b) fleshes out the relationship between
PandasDelegate
andAccessorProperty
in docstrings,c) provides a new
wrap_delegate_names
class decorator as an alternative toPandasDelegate._add_delegate_accessors
for pinning specifying the delegated properties/methods,d) implements tests for custom accessors.
git diff upstream/master -u -- "*.py" | flake8 --diff