-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Cleanup & De-duplication for custom offset classes #18640
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
Cleanup & De-duplication for custom offset classes #18640
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18640 +/- ##
==========================================
- Coverage 91.59% 91.58% -0.02%
==========================================
Files 155 153 -2
Lines 51255 51234 -21
==========================================
- Hits 46948 46922 -26
- Misses 4307 4312 +5
Continue to review full report at Codecov.
|
pandas/tseries/offsets.py
Outdated
@@ -413,6 +413,25 @@ def _from_name(cls, suffix=None): | |||
return cls() | |||
|
|||
|
|||
class _CustomMixin(object): | |||
""" | |||
mixin for classes that define and validate calendar, holidays, |
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.
Capitalize "mixin"
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.
There's one below BusinessMixin
that you can also fix.
pandas/tseries/offsets.py
Outdated
self._offset = offset | ||
|
||
@cache_readonly | ||
def next_bday(self): | ||
# used for moving to next businessday |
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.
If you're going to discuss what the function does, let's use a doc-string instead of a comment.
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.
This comment is retained from the existing version of the method, not sure it merits a full-on docstring. But will do.
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 fine. pls update docs as per @gfyoung comments.
thanks @jbrockmendel pls document anything you can (you are already doing this), but more is better than less. yes doc-strings are boring :<, but this helps improve things even more. |
Will do. Current gameplan vis-a-vis offsets:
|
The diff looks a little bit mangled. This PR does two things.
Centralize frequently-repeated calendar
__init__
in a new _CustomMixinMerge a bunch of shared CustomBusinessMonthEnd and CustomBusinessMonthBegin logic into a parent class.
git diff upstream/master -u -- "*.py" | flake8 --diff