Skip to content

Reproducibility: simulation.py relies on global np.random state instead of a seeded Generator #5

Description

@joelsansana

simulation.py calls np.random.seed(seed) once in run_with(), then draws randomness via the global-state functions np.random.randn() / np.random.rand() at 8+ call sites (ARMAX noise, quality-latching lab noise, filter-clog variance, sensor intermittence).

This works as long as nothing else in the process touches np.random between calls, but it's implicit shared mutable state — exactly what the project's byte-identical fingerprint contract shouldn't depend on. Contrast with fouling_modes.py, which does this correctly: FoulingModeStepper.step() takes an explicit rng: np.random.Generator parameter.

Suggested fix: thread an explicit np.random.default_rng(seed) through run_with() and its helper functions, matching the pattern already used in fouling_modes.py.

Files: bdsim/simulation.py

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions