Skip to content

to replace random.seed(seed=None) using dedicated Generator instance(… #25765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions galleries/plot_types/basic/scatter_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
plt.style.use('_mpl-gallery')

# make the data
np.random.seed(3)
x = 4 + np.random.normal(0, 2, 24)
y = 4 + np.random.normal(0, 2, len(x))
rng = np.random.default_rng(seed=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rng = np.random.default_rng(seed=None)
rng = np.random.default_rng(seed=19680801)

We use 19680801 as the seed anyplace we have to put in a seed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true for the "Plot types" examples. They all use 3, likely because they were taken from the cheat sheets. I'm in (weak) favour of keeping that (a) for consistency and (b) because 19680801 is more noisy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qqwqqw689 This needs a seed. I'd use "3" in this case as well.

I'm not clear why you have only changed one example.


x = 4 + rng.normal(0, 2, 24)
y = 4 + rng.normal(0, 2, len(x))
# size and color:
sizes = np.random.uniform(15, 80, len(x))
colors = np.random.uniform(15, 80, len(x))
sizes = rng.uniform(15, 80, len(x))
colors = rng.uniform(15, 80, len(x))

# plot
fig, ax = plt.subplots()
Expand Down