-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Make some attributes of DateOffset read-only; add tests #17181
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
Make some attributes of DateOffset read-only; add tests #17181
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17181 +/- ##
==========================================
- Coverage 90.99% 90.98% -0.02%
==========================================
Files 162 162
Lines 49508 49543 +35
==========================================
+ Hits 45052 45076 +24
- Misses 4456 4467 +11
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17181 +/- ##
==========================================
- Coverage 91% 90.98% -0.02%
==========================================
Files 162 162
Lines 49508 49530 +22
==========================================
+ Hits 45055 45067 +12
- Misses 4453 4463 +10
Continue to review full report at Codecov.
|
pandas/tseries/offsets.py
Outdated
# DateOffset needs to be effectively immutable in order for the | ||
# caching in _cached_params to be correct. | ||
frozen = ['n', '_offset', 'normalize', '_inc'] | ||
if name in frozen and hasattr(self, name): |
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.
so this needs a deprecation cycle for n & normalize, rather than raising here.
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 PR is not a long-term solution. Instead how about we have it clear the cache whenever an attribute is re-set? That should ensure correctness without breaking backward-compatibility.
16e2661
to
a888af5
Compare
Hello @jbrockmendel! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on August 26, 2017 at 19:25 Hours UTC |
I've got a much better approach that can be implemented if/when #17274 is merged. Closing this to be replaced at a later date. |
This PR takes over for #17137. That PR tried to handle the general case of this issue, but ultimately doing that correctly would require a much more extreme refactoring.
This PR only used a cached version of
_params
whenkwds
is empty. This special case covers'M', 'D', 'H', 'min', 'sec', 'ms', 'us', 'ns'
special cases.I plan to extend this to cover at least the Annual and Quarterly cases, but doing that carefully may take a while, so this can get the ball rolling.
git diff upstream/master -u -- "*.py" | flake8 --diff