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

dates: Rewrite using regular expressions #928

Closed
wants to merge 12 commits into from

Conversation

victorlin
Copy link
Member

@victorlin victorlin commented May 16, 2022

Description of proposed changes

This rewrites the date parsing functions currently used by filter and frequencies --min-date/--max-date parameters. Note that it doesn't affect the date parsing functions used for the metadata dates within augur filter.

Related issue(s)

Testing

  • Updated doctests and pytests.
  • Checks pass

@victorlin victorlin self-assigned this May 16, 2022
@victorlin victorlin force-pushed the dates/improve-parsing branch from f36b3f0 to f3ee9b9 Compare May 17, 2022 04:41
@victorlin victorlin force-pushed the dates/improve-parsing branch 3 times, most recently from 49bf6ff to 215fb80 Compare May 18, 2022 17:10
@codecov
Copy link

codecov bot commented May 18, 2022

Codecov Report

Base: 68.08% // Head: 68.23% // Increases project coverage by +0.14% 🎉

Coverage data is based on head (aeea545) compared to base (85d2edd).
Patch coverage: 96.82% of modified lines in pull request are covered.

❗ Current head aeea545 differs from pull request most recent head 3627df2. Consider uploading reports for the commit 3627df2 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #928      +/-   ##
==========================================
+ Coverage   68.08%   68.23%   +0.14%     
==========================================
  Files          62       62              
  Lines        6690     6727      +37     
  Branches     1641     1649       +8     
==========================================
+ Hits         4555     4590      +35     
  Misses       1829     1829              
- Partials      306      308       +2     
Impacted Files Coverage Δ
augur/dates.py 93.69% <96.42%> (+0.45%) ⬆️
augur/__version__.py 100.00% <100.00%> (ø)
augur/filter/__init__.py 100.00% <100.00%> (ø)
augur/frequencies.py 51.66% <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 force-pushed the dates/improve-parsing branch 2 times, most recently from e987104 to 505c7b9 Compare May 18, 2022 18:25
@victorlin victorlin marked this pull request as ready for review May 18, 2022 18:36
@victorlin victorlin requested a review from a team May 18, 2022 20:13
j23414
j23414 previously approved these changes May 18, 2022
Copy link
Contributor

@j23414 j23414 left a comment

Choose a reason for hiding this comment

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

Slick, especially in the 'any_to_numeric_type_min/max'.

As far as I can tell from reading the code, looks good to me.

@victorlin
Copy link
Member Author

Converting to draft, at least until #989 is resolved

@victorlin victorlin marked this pull request as draft June 24, 2022 19:15
@tsibley
Copy link
Member

tsibley commented Jun 24, 2022

Is the plan to eventually replace the remaining treetime-based functions like augur.date.get_numerical_dates() with the new ones introduced here?

@victorlin
Copy link
Member Author

@tsibley yes, that's my plan with #938

@victorlin victorlin force-pushed the dates/improve-parsing branch 3 times, most recently from 917dc79 to 6229db7 Compare July 1, 2022 18:16
@victorlin victorlin force-pushed the dates/improve-parsing branch from 6229db7 to 53cb6c1 Compare November 8, 2022 22:57
To be more accurate and remove duplication.
@victorlin victorlin force-pushed the dates/improve-parsing branch from 53cb6c1 to 9460e6c Compare January 25, 2023 21:59
@victorlin
Copy link
Member Author

While re-reading through the commits, I realized it was hard to follow. Just rebased and force-pushed with more verbose commits which should hopefully help make sense of the changes here.

@victorlin victorlin force-pushed the dates/improve-parsing branch from aeea545 to 6a18b35 Compare January 25, 2023 23:03
@victorlin victorlin marked this pull request as ready for review January 25, 2023 23:06
@victorlin victorlin requested a review from a team January 25, 2023 23:06
@victorlin victorlin dismissed stale reviews from tsibley and j23414 January 26, 2023 00:04

PR contents updated

One function per supported date format makes the top-level
numeric_date() easier to follow.
This was previously implicit, but having it explicitly makes the flow
more clear.
This rewrites the date parsing functions currently used by filter and
frequencies --min-date/--max-date parameters. Note that current logic is
retained.
Don't support non-positive years as those years are outside the range of
the ISO 8601 standard.
Support both ambiguous dates (e.g. 2020-XX-XX) and incomplete dates
(e.g. 2020-06, 2020).
By centralizing all calls to a final base case, this will make it easier
to add options such as min/max bounds. It also makes usage of
treetime.utils.numeric_date more clear.
This fix a bug¹ where incomplete dates such as --max-date 2018 would not
be inclusive, since that had previously resolved to --max-date 2018-01-01.

¹ nextstrain#893
@victorlin victorlin force-pushed the dates/improve-parsing branch from 6a18b35 to 3627df2 Compare January 27, 2023 01:35
@victorlin
Copy link
Member Author

Marking as draft again since this needs to go through some more changes following merge of #1140.

@victorlin victorlin marked this pull request as draft January 28, 2023 00:22
@victorlin
Copy link
Member Author

Closing this in favor of #1144, which is an attempt to tackle the same problems while consolidating logic simultaneously.

@victorlin victorlin closed this Jan 31, 2023
@victorlin victorlin deleted the dates/improve-parsing branch January 31, 2023 01:22
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.

filter: --max-date with year only is not inclusive
5 participants