fix: make three-period ITS test fixtures order-independent#960
Draft
anevolbap wants to merge 1 commit into
Draft
fix: make three-period ITS test fixtures order-independent#960anevolbap wants to merge 1 commit into
anevolbap wants to merge 1 commit into
Conversation
The datetime_data and integer_data fixtures drew from the session-scoped rng fixture, so the generated data depended on how many draws earlier tests consumed. Any change to test collection order could flip the persistence_ratio >= 0 assertion, which is also wrong in general: a negative ratio is a legitimate outcome when the counterfactual sits above the observed post-period. Seed both fixtures with their own generator and drop the sign assertion. Fixes #959
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #960 +/- ##
=======================================
Coverage 95.16% 95.16%
=======================================
Files 93 93
Lines 15030 15030
Branches 896 896
=======================================
Hits 14304 14304
Misses 507 507
Partials 219 219 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #959.
datetime_dataandinteger_dataintest_three_period_its.pydrew from the session-scopedrngfixture, so the generated data depended on how many random draws earlier tests consumed. Any PR that changed test collection (like #851, which removed one parametrize case in an unrelated file) shifted the stream and could fliptest_analyze_persistence_sklearn, whosepersistence_ratio >= 0assertion only holds for some draws.Changes
rng.persistence_ratio >= 0assertions in the pymc and sklearn persistence tests. A negative ratio is a legitimate outcome when the counterfactual sits above the observed post-period.Testing
pytest causalpy/tests/test_instrumental_variable.py causalpy/tests/test_three_period_its.py) now passes: 54 passed.