Skip to content

One way to draw the seed an unseeded multi-run result shares - #507

Merged
derrynknife merged 1 commit into
devfrom
build/shared-seed
Nov 21, 2026
Merged

derrynknife merged 1 commit into
devfrom
build/shared-seed

Conversation

@derrynknife

Copy link
Copy Markdown
Owner

Summary

Results made of several runs on one seed drew that seed, when none was given, from the operating system's entropy, which np.random.seed does not reach. They now take it through rbd._streams.shared_seed, as cost_by_window already does, so an unseeded call is repeatable under np.random.seed and is the seeded call of the seed drawn:

  • npv_distribution, compare_npv, least_spend_for_downtime (through _npv_runs._seed)
  • best_switch_time (_switch_runs)
  • RepairOrReplace.unit_decision / unit_decisions with uncertainty
  • value_plan requests for a seeded analysis (_contract)

Each seed docstring says how an unseeded call draws its seed. Seeded results are unchanged.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / tooling
  • Breaking change

Checklist

  • Tests added/updated (test_shared_seeds.py: each call unseeded under np.random.seed(k) against the seeded call of the seed drawn)
  • black, isort, flake8 and mypy on the changed files; tests of what changed: test_shared_seeds, test_npv_distribution, test_switch_time_diagram, test_repair_or_replace, test_value_plan, test_downtime_risk, test_window_report (98 passed, 1 skipped) and the touched modules' doctests (9 passed)
  • Anything that must agree with the change is updated with it
  • CHANGELOG.md updated under [Unreleased]
  • Any Monte-Carlo tests are seeded (deterministic)

Notes for reviewers

RepairOrReplace.fleet_policy without a seed still draws its own bands from fresh entropy: it is one draw, not runs that must share a seed.


Generated by Claude Code

npv_distribution, compare_npv, least_spend_for_downtime,
best_switch_time, RepairOrReplace's unit decisions and value_plan's
requests drew the seed their runs share from OS entropy, which
np.random.seed did not reach. They now take it through
_streams.shared_seed, as cost_by_window does. Seeded results are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6RpnXB87vwhYETeh7ihtA
@derrynknife
derrynknife merged commit 813c390 into dev Nov 21, 2026
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