Skip to content

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

Closed

Conversation

jbrockmendel
Copy link
Member

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 when kwds 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.

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

@gfyoung gfyoung added Enhancement Performance Memory or execution speed performance labels Aug 6, 2017
@codecov
Copy link

codecov bot commented Aug 6, 2017

Codecov Report

Merging #17181 into master will decrease coverage by 0.01%.
The diff coverage is 96%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 88.76% <96%> (ø) ⬆️
#single 40.27% <70%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/tseries/offsets.py 97.06% <96%> (-0.07%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.66% <0%> (-0.1%) ⬇️

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 929c66f...16e2661. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 6, 2017

Codecov Report

Merging #17181 into master will decrease coverage by 0.01%.
The diff coverage is 97.22%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 88.77% <97.22%> (ø) ⬆️
#single 40.27% <88.88%> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/tseries/offsets.py 97.1% <97.22%> (-0.03%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.71% <0%> (-0.1%) ⬇️

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 7bef6d8...7690d29. Read the comment docs.

# 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):
Copy link
Contributor

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.

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 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.

@jbrockmendel jbrockmendel force-pushed the date_offset_immutable2 branch from 16e2661 to a888af5 Compare August 9, 2017 02:34
@pep8speaks
Copy link

pep8speaks commented Aug 9, 2017

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

@jbrockmendel
Copy link
Member Author

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.

@jbrockmendel jbrockmendel deleted the date_offset_immutable2 branch August 30, 2017 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants