From 714636e2507e93af4674a76e596302352dc4ebb9 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Mon, 1 May 2023 22:40:49 +0200 Subject: [PATCH] Replace random values by hard-coded numbers in plot-types ... ... for the cases where we have only very few random numbers. This makes the code a bit simpler, because we do not have to seed. Also, a list of hard-coded numbers is slightly simpler to grasp compared to a rng function. This is partly also in anticipation of the switch to numpy's rng generator classes. While conceptually superior, they are a bit more verbose and introduce the additional local variable `rng` (IMHO this is the benefit and the downside: It explicitly ties the rng state to the local context -> clarity. But OTOH the user is bothered with this local state even if it's not important to them - like in our examples.) --- galleries/plot_types/basic/bar.py | 3 +-- galleries/plot_types/basic/stem.py | 3 +-- galleries/plot_types/basic/step.py | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/galleries/plot_types/basic/bar.py b/galleries/plot_types/basic/bar.py index cc310f7a464b..005e85c5e2ba 100644 --- a/galleries/plot_types/basic/bar.py +++ b/galleries/plot_types/basic/bar.py @@ -11,9 +11,8 @@ plt.style.use('_mpl-gallery') # make data: -np.random.seed(3) x = 0.5 + np.arange(8) -y = np.random.uniform(2, 7, len(x)) +y = [4.8, 5.5, 3.5, 4.6, 6.5, 6.6, 2.6, 3.0] # plot fig, ax = plt.subplots() diff --git a/galleries/plot_types/basic/stem.py b/galleries/plot_types/basic/stem.py index 8e7b29283c01..a606482ecf9b 100644 --- a/galleries/plot_types/basic/stem.py +++ b/galleries/plot_types/basic/stem.py @@ -11,9 +11,8 @@ plt.style.use('_mpl-gallery') # make data -np.random.seed(3) x = 0.5 + np.arange(8) -y = np.random.uniform(2, 7, len(x)) +y = [4.8, 5.5, 3.5, 4.6, 6.5, 6.6, 2.6, 3.0] # plot fig, ax = plt.subplots() diff --git a/galleries/plot_types/basic/step.py b/galleries/plot_types/basic/step.py index 558550a5c498..6044262e6d1f 100644 --- a/galleries/plot_types/basic/step.py +++ b/galleries/plot_types/basic/step.py @@ -11,9 +11,8 @@ plt.style.use('_mpl-gallery') # make data -np.random.seed(3) x = 0.5 + np.arange(8) -y = np.random.uniform(2, 7, len(x)) +y = [4.8, 5.5, 3.5, 4.6, 6.5, 6.6, 2.6, 3.0] # plot fig, ax = plt.subplots()