Skip to content

TST: seed the starting point in test_rotated_hyper_ellipsoid - #994

Open
jadhavgaurav wants to merge 1 commit into
QuantEcon:mainfrom
jadhavgaurav:tst-seed-rotated-hyper-ellipsoid
Open

jadhavgaurav wants to merge 1 commit into
QuantEcon:mainfrom
jadhavgaurav:tst-seed-rotated-hyper-ellipsoid

Conversation

@jadhavgaurav

Copy link
Copy Markdown
Contributor

Closes #993

test_rotated_hyper_ellipsoid drew its start point from the unseeded global generator. This draws it from np.random.default_rng(42) instead, so the test is deterministic. It is the only unseeded draw in test_nelder_mead.py. No source change.

Why seed 42: I swept seeds 0 to 2999 with the same objective, bounds and tolerances as the test. 2 of 3000 starts miss the atol=1e-6 check (seeds 117 and 2704, errors 1.2e-4 and 3.4e-4), about 0.07%, in line with the rate in the issue. Seed 42 reaches max|x| = 1.3e-8 and fun = -1.3e-15, so it passes with a wide margin and is not a borderline pick.

Not vacuous: the objective, bounds, tolerances and assertions are unchanged, and the start is an ordinary N(0, 1)^5 draw (max|x0| = 1.95 for seed 42), not a hand-picked easy point. Temporarily setting the seed to 117 makes this same test fail (max absolute difference 1.2e-4), so the assertions still detect a non-converged run.

Checks:

  • pytest quantecon/optimize/tests/test_nelder_mead.py: 22 passed.
  • The file run 50 times with the fix: 0 failures. The file run 50 times before the fix also gave 0 failures, which is expected at a 0.07% per-run rate; the seed sweep above is the reproduction.
  • flake8 --select=F401,F405,E231 quantecon: clean.
  • The full test suite was not run.

Assisted-by: Claude Code (Claude Sonnet 5.5)

Draw x0 from default_rng(42) instead of the unseeded global generator, so the test no longer fails on rare starting points (QuantEcon#993).

Signed-off-by: Gaurav Jadhav <[email protected]>
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.136%. remained the same — jadhavgaurav:tst-seed-rotated-hyper-ellipsoid into QuantEcon:main

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.

TST: seed the starting point in test_rotated_hyper_ellipsoid

2 participants