Skip to content

Bug: DataGenerator uses global random state instead of instance-level RNG #6

@osherlock1

Description

@osherlock1

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions