Skip to content

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

Merged
merged 8 commits into from
Dec 6, 2017

Conversation

jbrockmendel
Copy link
Member

The diff looks a little bit mangled. This PR does two things.

  1. Centralize frequently-repeated calendar __init__ in a new _CustomMixin

  2. Merge a bunch of shared CustomBusinessMonthEnd and CustomBusinessMonthBegin logic into a parent class.

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@codecov
Copy link

codecov bot commented Dec 5, 2017

Codecov Report

Merging #18640 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 89.44% <100%> (ø) ⬆️
#single 40.66% <65.78%> (-0.12%) ⬇️
Impacted Files Coverage Δ
pandas/tseries/offsets.py 96.86% <100%> (-0.04%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.81% <0%> (-0.1%) ⬇️
pandas/core/categorical.py 95.64% <0%> (-0.02%) ⬇️
pandas/io/wb.py
pandas/io/data.py
pandas/util/testing.py 82.01% <0%> (+0.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a764663...2274cc3. Read the comment docs.

@gfyoung gfyoung added Clean Internals Related to non-user accessible pandas implementation Timedelta Timedelta data type labels Dec 5, 2017
@@ -413,6 +413,25 @@ def _from_name(cls, suffix=None):
return cls()


class _CustomMixin(object):
"""
mixin for classes that define and validate calendar, holidays,
Copy link
Member

Choose a reason for hiding this comment

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

Capitalize "mixin"

Copy link
Member

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.

self._offset = offset

@cache_readonly
def next_bday(self):
# used for moving to next businessday
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Contributor

@jreback jreback left a 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.

@jreback jreback added this to the 0.22.0 milestone Dec 6, 2017
@jreback jreback merged commit de6e107 into pandas-dev:master Dec 6, 2017
@jreback
Copy link
Contributor

jreback commented Dec 6, 2017

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.

@jbrockmendel jbrockmendel deleted the tslibs-offsets-custom2 branch December 6, 2017 04:10
@jbrockmendel
Copy link
Member Author

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:

  • fix confusing (several GH issues) naming scheme in Quarter offsets, pending getting the "go-ahead"
  • hope/ask for help with the cython-immutability goal, since that will entail a major perf win.
  • update/fix docs on "anchored", implement a few missing non-anchored (Year, Quarter, Month, Day) offsets
  • distinguish between offsets that are Period-friendly vs just-for-date_range (there are a bunch of GH issues that boil down to confusion on this point)
  • fix issues with Tick comparison methods (1+ GH issues)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Internals Related to non-user accessible pandas implementation Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants