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

Update call and expected returns from pandas's parse_time_string #601

Merged
merged 1 commit into from
Aug 11, 2020

Conversation

huddlej
Copy link
Contributor

@huddlej huddlej commented Aug 11, 2020

Description of proposed changes

The API for parse_time_string changed recently to only return two values instead of three and the function is no longer importable from the pandas core tools datetimes module as of version 1.1.0. Instead, we have to import the parsing module that exposes the parse_time_string function. This commit supports both the previous and new API's return values.

This bug should affect anyone trying to run augur with pandas 1.1.0 but not users running earlier versions of pandas.

We might consider not using this pandas function if it is truly part of pandas' internal API.

Testing

To test this, I setup the same environment as the CI and confirmed that the test failed. After applying the patch from this PR, the test passes.

# Setup the environment
conda env create -f environment.yml
conda activate augur
pip install -e .[dev]

# Run the affected test
python3 -m pytest -c pytest.python3.ini -k test_fix_dates

@huddlej huddlej marked this pull request as draft August 11, 2020 19:46
@codecov
Copy link

codecov bot commented Aug 11, 2020

Codecov Report

Merging #601 into master will increase coverage by 0.01%.
The diff coverage is 60.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #601      +/-   ##
==========================================
+ Coverage   26.58%   26.59%   +0.01%     
==========================================
  Files          36       36              
  Lines        5278     5282       +4     
  Branches     1306     1307       +1     
==========================================
+ Hits         1403     1405       +2     
- Misses       3825     3826       +1     
- Partials       50       51       +1     
Impacted Files Coverage Δ
augur/parse.py 50.00% <60.00%> (ø)

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 76c04eb...7b11575. Read the comment docs.

The API for `parse_time_string` changed recently to only return two values
instead of three [1] and the function is no longer importable from the pandas
core tools datetimes module as of version 1.1.0. Instead, we have to import the
`parsing` module that exposes the `parse_time_string` function. This commit
supports both the previous and new API's return values.

This bug should affect anyone trying to run augur with pandas 1.1.0 but not
users running earlier versions of pandas.

[1] pandas-dev/pandas#31065
@huddlej huddlej marked this pull request as ready for review August 11, 2020 20:06
@huddlej huddlej requested review from tsibley and rneher August 11, 2020 20:09
Copy link
Member

@tsibley tsibley left a comment

Choose a reason for hiding this comment

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

I've not tested this myself, but by inspection it looks good to me.

pandas.to_datetime() looks like the public API, but it only returns a pandas.Timestamp and doesn't provide the input resolution differentiator we use. So for now I'd say let's merge this, and we can circle back to switching to a public API later.

@huddlej
Copy link
Contributor Author

huddlej commented Aug 11, 2020

Thanks for the quick check, @tsibley!

@huddlej huddlej merged commit 47ee1c9 into master Aug 11, 2020
@huddlej huddlej deleted the fix-pandas-regression branch August 11, 2020 21:26
@huddlej huddlej added this to the Major release 10.0.0 milestone Aug 12, 2020
@victorlin victorlin mentioned this pull request Mar 11, 2024
2 tasks
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.

2 participants