Skip to content
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

frequencies: Calculate all pivot points based on end pivot #1150

Merged
merged 3 commits into from
Mar 8, 2023

Conversation

victorlin
Copy link
Member

@victorlin victorlin commented Feb 13, 2023

Description of proposed changes

Previously, monthly pivots calculated from the end of a month failed to account for the variation in the number of days per month.

Related issue(s)

Fixes #963

Testing

  • Added tests to reflect change in behavior
  • Checks pass

Checklist

  • Add a message in CHANGES.md summarizing the changes in this PR that are end user focused. Keep headers and formatting consistent with the rest of the file.

@victorlin victorlin self-assigned this Feb 13, 2023
@codecov
Copy link

codecov bot commented Feb 13, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change

Comparison is base (797af0d) 68.19% compared to head (004d017) 68.19%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1150   +/-   ##
=======================================
  Coverage   68.19%   68.19%           
=======================================
  Files          63       63           
  Lines        6748     6748           
  Branches     1654     1654           
=======================================
  Hits         4602     4602           
  Misses       1838     1838           
  Partials      308      308           
Impacted Files Coverage Δ
augur/frequency_estimators.py 36.16% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@victorlin victorlin marked this pull request as ready for review February 13, 2023 13:34
Copy link
Contributor

@huddlej huddlej left a comment

Choose a reason for hiding this comment

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

This looks great, @victorlin! Could we mention somewhere that this fix is necessary because of the nature of Python's various timedelta implementation (i.e., that pivot = pivot - delta iteratively applied will produce a different result than pivot = end - delta * len(pivots)? It's a subtle point that might have been documented in other standard Python tools, but it would be useful to document for ourselves, too.

augur/frequency_estimators.py Show resolved Hide resolved
tests/test_frequencies.py Show resolved Hide resolved
This shows the current behavior, to be changed by the following commit.
Previously, monthly pivots calculated from the end of a month failed to
account for the variation in the number of days per month. This was due
to subtle differences between subtracting an isodate.Duration against a
decremental date (previous implementation) and subtracting an
isodate.Duration with a multiplier against a fixed date (new
implementation).

Tests updated with the new behavior.
@victorlin victorlin force-pushed the victorlin/fix-frequencies-pivots branch from 16776ab to 004d017 Compare March 7, 2023 01:00
@victorlin
Copy link
Member Author

victorlin commented Mar 7, 2023

Could we mention somewhere that this fix is necessary because of the nature of Python's various timedelta implementation (i.e., that pivot = pivot - delta iteratively applied will produce a different result than pivot = end - delta * len(pivots)?

@huddlej I added more explanation in the commit message (dde579b). Does that look better?

@victorlin victorlin requested a review from huddlej March 7, 2023 01:04
Copy link
Contributor

@huddlej huddlej left a comment

Choose a reason for hiding this comment

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

Thank you for the updated commit message, @victorlin. This looks ready to merge!

@victorlin victorlin merged commit f10497e into master Mar 8, 2023
@victorlin victorlin deleted the victorlin/fix-frequencies-pivots branch March 8, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

frequencies: Number of pivot points differs for same date range when both start/end date are inclusive
2 participants