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

utils: Fix numeric date handling #841

Merged

Conversation

victorlin
Copy link
Member

@victorlin victorlin commented Feb 3, 2022

Description of proposed changes

Currently, date format handling is inaccurate (#747) as numeric dates are thrown out:

augur/augur/utils.py

Lines 115 to 119 in a85194c

if type(value)!=str:
if raise_error:
raise ValueError(value)
else:
numerical_date = None

This change ensures numeric dates are processed, and that non-negative integers are evaluated as year-only ambiguous dates.

Also including a few refactors:

  • Remove raise_error parameter. The intent is unclear and tests still pass without it.
  • Use return instead of an intermediate variable.

Related issue(s)

Fixes #747.

Testing

  • Add broken tests and verify new changes pass.
  • Fix inaccurate existing tests.

@codecov
Copy link

codecov bot commented Feb 3, 2022

Codecov Report

Merging #841 (bfffeca) into master (a85194c) will increase coverage by 0.07%.
The diff coverage is 78.57%.

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #841      +/-   ##
==========================================
+ Coverage   33.83%   33.91%   +0.07%     
==========================================
  Files          41       41              
  Lines        5905     5906       +1     
  Branches     1507     1507              
==========================================
+ Hits         1998     2003       +5     
+ Misses       3824     3821       -3     
+ Partials       83       82       -1     
Impacted Files Coverage Δ
augur/utils.py 42.89% <78.57%> (+1.30%) ⬆️

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 a85194c...bfb21da. Read the comment docs.

@victorlin victorlin requested a review from a team February 3, 2022 01:05
@victorlin victorlin marked this pull request as ready for review February 3, 2022 01:06
@victorlin victorlin changed the title Fix date handling utils: Fix numeric date handling Feb 3, 2022
@huddlej huddlej self-requested a review February 3, 2022 04:55
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.

Thanks, @victorlin! This looks great.

augur/utils.py Show resolved Hide resolved
@victorlin victorlin merged commit 84f11b4 into nextstrain:master Feb 4, 2022
@victorlin victorlin deleted the filter/fix-incomplete-date-handling branch February 4, 2022 01:26
@victorlin victorlin added this to the Major release 14.0.0 milestone Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incomplete dates are not interpreted as ambiguous by augur filter
2 participants