Repository navigation
Seed the LBA simulators from random_state - #457
Conversation
The four LBA kernels drew from NumPy's global generator and had no random_state parameter, so the seed was dropped into **kwargs and the same seed gave different data on every call and in every process. Each kernel now takes random_state and draws from np.random.default_rng(random_state). This changes the seeded output of lba2, lba3, lba4, lba_3_vs_constraint, lba_angle_3, lba_angle_3_vs_constraint and the three dev_rlwm_lba_* models; np.random.seed no longer controls it. The new test runs these models in two fresh interpreters and compares the output. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
At the default 0.8, one of twelve sampler seeds diverged on the seed-5 dataset of the fixed simulator (lnccbrown/ssm-simulators#457). At 0.95 none of twelve does, on ssm-simulators 0.17.0 and on the fix. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Closes #399.
src/cssm/lba_models.pyxdrew from NumPy's global generator and had norandom_stateparameter, so the seed was dropped into**kwargs. The same seed gave different data on every call and in every process.random_stateand draws fromnp.random.default_rng(random_state).lba2,lba3,lba4,lba_3_vs_constraint,lba_angle_3,lba_angle_3_vs_constraintand the threedev_rlwm_lba_*models. A scan of all 124 registered models found no other model that is not reproducible for a fixed seed.np.random.seedno longer controls it, and a negativerandom_statenow raisesValueError, as the other kernels already do (ValueErrororOverflowError).tests/test_lba_random_state.pyruns the nine models in two fresh interpreters: same seed gives the same data, different seeds give different data. It fails onmain.uv run pytest tests/(1770 passed, 154 skipped),uv run pytest tests/test_parallel_equivalence.py --run-statistical --no-cov(56 passed),uv run ruff check . && uv run ruff format --check ..src/cssm/sequential_models.pyxholds four unreferenced copies of these kernels that still usenp.random.🤖 Generated with Claude Code
Summary by CodeRabbit