Skip to content

Honour the random state a plot was given - #1120

Merged
has2k1 merged 7 commits into
mainfrom
randomstate-pickling
Sep 4, 2026
Merged

Honour the random state a plot was given#1120
has2k1 merged 7 commits into
mainfrom
randomstate-pickling

Conversation

@has2k1

@has2k1 has2k1 commented Sep 4, 2026

Copy link
Copy Markdown
Owner

fixes #1115

Define one conversion boundary for integer seeds and use it for jitter.
Existing generators and `None` remain unchanged. Callers can therefore
normalise stored parameters once when several draws must advance one
stream.
Drawing an unseeded `geom_sina` stored NumPy's `random` module in the
plot parameters. Copying the plot then raised
`TypeError: cannot pickle 'module' object`.

Preserve the unset state until drawing needs NumPy's global random
generator.
`position_jitter` and `position_jitterdodge` created a new generator
for each axis. A fixed seed therefore produced identical horizontal
and vertical offsets, placing points along a diagonal. They also
treated zero as an absent seed.

Initialise one generator during setup so both axes draw from the same
advancing stream and zero remains valid.
`stat_summary` and `stat_summary_bin` treated `random_state=0` as absent
and drew from NumPy's global random state.

Preserve zero so repeated summaries use the same seeded stream.
`random_state` parameters now accept NumPy `Generator` instances in
addition to integer seeds and `RandomState` instances.

Bootstrap summaries draw sample indices through the generator interface.
Other randomised operations use its shared sampling methods.
The `&` and `*` operators copied each broadcast layer shallowly.
Mutable parameters resolved while drawing one plot were then visible to
the others.

Give every target plot an independent copy so each plot draws from its
own layer state.
Document support for NumPy `Generator` instances, valid zero seeds,
independent axis jitter, copyable unseeded Sina plots, and isolated
broadcast layers in compositions.
@has2k1
has2k1 merged commit 1f5ee9f into main Sep 4, 2026
13 of 14 checks passed
@has2k1
has2k1 deleted the randomstate-pickling branch September 4, 2026 12:33
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.

plot composition: Cannot add geom_sina to all plots in a composition

1 participant