From 4b5aed5e390872cc162676d219c8f265f744e535 Mon Sep 17 00:00:00 2001 From: qqwqqw689 <114795525+qqwqqw689@users.noreply.github.com> Date: Tue, 25 Apr 2023 07:11:37 +0800 Subject: [PATCH 1/2] to replace random.seed(seed=None) using dedicated Generator instance(according to numpy reference) --- galleries/plot_types/basic/scatter_plot.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/galleries/plot_types/basic/scatter_plot.py b/galleries/plot_types/basic/scatter_plot.py index 792016c0e79c..7ed10363e804 100644 --- a/galleries/plot_types/basic/scatter_plot.py +++ b/galleries/plot_types/basic/scatter_plot.py @@ -11,12 +11,14 @@ plt.style.use('_mpl-gallery') # make the data +rng = np.random.default_rng(seed=None) np.random.seed(3) -x = 4 + np.random.normal(0, 2, 24) -y = 4 + np.random.normal(0, 2, len(x)) + +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() @@ -26,4 +28,4 @@ ax.set(xlim=(0, 8), xticks=np.arange(1, 8), ylim=(0, 8), yticks=np.arange(1, 8)) -plt.show() +plt.show() \ No newline at end of file From f0b97211bbc1f6202cc546bad911e0efaa00227e Mon Sep 17 00:00:00 2001 From: qqwqqw689 <114795525+qqwqqw689@users.noreply.github.com> Date: Tue, 25 Apr 2023 15:21:14 +0800 Subject: [PATCH 2/2] Update scatter_plot.py --- galleries/plot_types/basic/scatter_plot.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/galleries/plot_types/basic/scatter_plot.py b/galleries/plot_types/basic/scatter_plot.py index 7ed10363e804..c6b9439a646e 100644 --- a/galleries/plot_types/basic/scatter_plot.py +++ b/galleries/plot_types/basic/scatter_plot.py @@ -12,7 +12,6 @@ # make the data rng = np.random.default_rng(seed=None) -np.random.seed(3) x = 4 + rng.normal(0, 2, 24) y = 4 + rng.normal(0, 2, len(x)) @@ -28,4 +27,4 @@ ax.set(xlim=(0, 8), xticks=np.arange(1, 8), ylim=(0, 8), yticks=np.arange(1, 8)) -plt.show() \ No newline at end of file +plt.show()