Skip to content

TST: actually seed TestForecasting fixtures - #865

Merged
bashtage merged 1 commit into
bashtage:mainfrom
heykav:fix/seed-forecast-fixtures
Sep 24, 2026
Merged

bashtage merged 1 commit into
bashtage:mainfrom
heykav:fix/seed-forecast-fixtures

Conversation

@heykav

@heykav heykav commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

TestForecasting.setup_class creates cls.rng = RandomState(12345) but never uses it — arch_model(dist=...) only takes a name, so every simulate() call used an unseeded default_rng(). Fixtures differed per run, making test_first_obs environment-dependent (fails on scipy 1.18.1, passes on 1.13.1).

  • Assign Normal(seed=cls.rng) via the public distribution setter before each simulate().
  • test_first_obs's pre-sliced vs first_obs= comparison solves two distinct optimizations; relaxed to rtol=atol=1e-4, matching test_holdback's identical comparison. Both fits report convergence_flag == 0.

Verified: test_forecast.py 530/530 on scipy 1.18.1 / numpy 2.5.3 / pandas 3.0.6, deterministic across repeated fresh runs.

setup_class created cls.rng = RandomState(12345) but never passed it
anywhere: arch_model's dist argument only accepts a name, so each
simulate() drew from an unseeded default_rng(). Fixture data changed
every run, which made test_first_obs pass or fail depending on the
environment (reproducibly fails on scipy 1.18.1).

Wire the seed in via the public distribution setter, and relax
test_first_obs's pre-sliced vs first_obs comparison to the same
rtol/atol=1e-4 that test_holdback already uses for the equivalent
two-fits comparison.
@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.54%. Comparing base (b4781d5) to head (83d1e94).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #865   +/-   ##
=======================================
  Coverage   99.54%   99.54%           
=======================================
  Files          78       78           
  Lines       15824    15829    +5     
  Branches     1294     1294           
=======================================
+ Hits        15752    15757    +5     
  Misses         38       38           
  Partials       34       34           
Flag Coverage Δ
adder 99.50% <100.00%> (+<0.01%) ⬆️
subtractor 99.50% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bashtage

Copy link
Copy Markdown
Owner

Thank you for catching this.

@bashtage
bashtage merged commit 91a25ef into bashtage:main Sep 24, 2026
23 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.

2 participants