pymc/unseeded-sampling
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| PyMC | error | unsafe, with xpd check --fix --unsafe-fixes |
All versions |
Unseeded PyMC sampling calls (pm.sample, pm.sample_prior_predictive, pm.sample_posterior_predictive, pm.sample_smc, pm.fit, and pm.draw) default to random_seed=None, producing different MCMC chains, variational fits, or predictive draws on every run. Passing random_seed=-1 raises ValueError in PyMC 6.
idata = pm.sample(draws=1000, tune=400)idata = pm.sample(draws=1000, tune=400, random_seed=0)ppc = pm.sample_posterior_predictive(idata, random_seed=None)ppc = pm.sample_posterior_predictive(idata, random_seed=0)What the rule reports
Section titled “What the rule reports”PyMC sampling, variational fitting, and forward drawing calls outside tests where random_seed= is omitted, None, or -1.
How to fix it
Section titled “How to fix it”Pass a non-negative integer seed (random_seed=0) or a seeded numpy.random.default_rng(0) instance.
Diagnostic message
Section titled “Diagnostic message”$F without a fixed random_seed= draws different posterior or predictive samples on every run. Pass random_seed=0 (or a seeded numpy.random.Generator).See all rules in the PyMC pack.