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

augur/parse.py: fix test failure with pandas 2.2. #1471

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

emollier
Copy link
Contributor

Description of proposed changes

This change fixes another case of change in pandas internals causing a breakage in the date parser; initial report is Debian bug #1071122.

Here is a copy of the test failure message for your convenience:

=================================== FAILURES ===================================
___________________________ TestParse.test_fix_dates ___________________________

self = <test_parse.TestParse object at 0x7fe8586a3590>
capsys = <_pytest.capture.CaptureFixture object at 0x7fe8582e7ce0>

    def test_fix_dates(self, capsys):
        full_date = "4-5-2020"
>       assert parse.fix_dates(full_date) == "2020-05-04"

tests/test_parse.py:14:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

d = '4-5-2020', dayfirst = True

    def fix_dates(d, dayfirst=True):
        '''
        attempt to parse a date string using pandas date parser. If ambiguous,
        the argument 'dayfirst' determines whether month or day is assumed to be
        the first field. Incomplete dates will be padded with XX.
        On failure to parse the date, the function will return the input.
        '''
        try:
>           from pandas.core.tools.datetimes import parsing
E           ImportError: cannot import name 'parsing' from 'pandas.core.tools.datetimes' (/usr/lib/python3/dist-packages/pandas/core/tools/datetimes.py)

augur/parse.py:34: ImportError

I agree adjusting the date parser to stick to pandas public api should be preferred; this change is available if need be.

Related issue(s)

Checklist

  • Checks pass: note I verified tests kept passing in Debian sid context with pandas 2.1, and were now passing with pandas 2.2 from Debian experimental.
  • If making user-facing changes, add a message in CHANGES.md summarizing the changes in this PR I did not make user facing changes I believe.

This change fixes another case of change in pandas internals causing a
breakage in the date parser; initial report is [Debian bug #1071122].

[Debian bug #1071122]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1071122

Signed-off-by: Étienne Mollier <emollier@debian.org>
@victorlin victorlin self-requested a review May 22, 2024 17:43
@victorlin victorlin mentioned this pull request May 22, 2024
4 tasks
@victorlin
Copy link
Member

@emollier thanks for surfacing these issues to us. I'll review this later, but for now I've opened an issue for us to support pandas v2 officially to prevent stuff like this from coming up on your side.

@corneliusroemer corneliusroemer mentioned this pull request Nov 10, 2024
4 tasks
Copy link
Member

@corneliusroemer corneliusroemer left a comment

Choose a reason for hiding this comment

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

Thanks, this is the same fix I arrived at. We should really stop using that internal pandas functionality though, I've made an issue for it #1670

@corneliusroemer corneliusroemer merged commit 6cfa08b into nextstrain:master Nov 10, 2024
20 checks passed
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.

3 participants