Skip to content

Conversation

@zhan7236
Copy link
Contributor

This PR adds a regression test for #55794.

The bug was that infer_freq had stateful behavior - calling it on a full index with duplicates would affect the result of subsequent calls on slices without duplicates. This has been fixed on main and this test ensures the fix is not regressed.

assert frequencies.infer_freq(times[:3]) == "D"

# Call on full index (which has duplicates, so returns None)
frequencies.infer_freq(times)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
frequencies.infer_freq(times)
assert frequencies.infer_freq(times) is None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks.

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Dec 1, 2025
@zhan7236 zhan7236 force-pushed the test-gh55794-infer-freq-stateful branch from 817b46b to c314835 Compare December 2, 2025 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Testing pandas testing functions or related to the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: infer_freq has stateful behavior

2 participants