Description
DataGenerator sets the global random seed in init via random.seed() and np.random.seed(). Because the seed is global, and other code that touches the random state between init and genearte_random_payload() will corrupt the sequence,
Root Cause
DataGenerator.init sets a global seed rather than storing a private np.random.Generator instance.
Expected behavor
Two DataGenerator instances created with the same seed should produce identical output regardless of when or how many times other generators were called in between.
Fix
Replace the global seed with an instance-level RNG:
self.rng = np.random.default_rng(seed)
Description
DataGenerator sets the global random seed in init via random.seed() and np.random.seed(). Because the seed is global, and other code that touches the random state between init and genearte_random_payload() will corrupt the sequence,
Root Cause
DataGenerator.init sets a global seed rather than storing a private np.random.Generator instance.
Expected behavor
Two DataGenerator instances created with the same seed should produce identical output regardless of when or how many times other generators were called in between.
Fix
Replace the global seed with an instance-level RNG:
self.rng = np.random.default_rng(seed)