Skip to content

Commit dbf9c44

Browse files
authored
Merge pull request matplotlib#7386 from NelleV/numpy_seed
DOC/ENH: examples are now reproducible
2 parents 00b3b8f + 2c08c49 commit dbf9c44

File tree

105 files changed

+332
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+332
-28
lines changed

examples/animation/basic_example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ def update_line(num, data, line):
1818

1919
fig1 = plt.figure()
2020

21+
# Fixing random state for reproducibility
22+
np.random.seed(19680801)
23+
2124
data = np.random.rand(2, 25)
2225
l, = plt.plot([], [], 'r-')
2326
plt.xlim(0, 1)

examples/animation/basic_example_writer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def update_line(num, data, line):
2020
line.set_data(data[..., :num])
2121
return line,
2222

23+
# Fixing random state for reproducibility
24+
np.random.seed(19680801)
25+
26+
2327
# Set up formatting for the movie files
2428
Writer = animation.writers['ffmpeg']
2529
writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)

examples/animation/bayes_update.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ def __call__(self, i):
5151
self.line.set_data(self.x, y)
5252
return self.line,
5353

54+
# Fixing random state for reproducibility
55+
np.random.seed(19680801)
56+
57+
5458
fig, ax = plt.subplots()
5559
ud = UpdateDist(ax, prob=0.7)
5660
anim = FuncAnimation(fig, ud, frames=np.arange(100), init_func=ud.init,

examples/animation/histogram.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
fig, ax = plt.subplots()
1818

19+
# Fixing random state for reproducibility
20+
np.random.seed(19680801)
21+
1922
# histogram our data with numpy
2023
data = np.random.randn(1000)
2124
n, bins = np.histogram(data, 100)

examples/animation/moviewriter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
import matplotlib.pyplot as plt
1818
import matplotlib.animation as manimation
1919

20+
# Fixing random state for reproducibility
21+
np.random.seed(19680801)
22+
23+
2024
FFMpegWriter = manimation.writers['ffmpeg']
2125
metadata = dict(title='Movie Test', artist='Matplotlib',
2226
comment='Movie support!')

examples/animation/rain.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import matplotlib.pyplot as plt
1313
from matplotlib.animation import FuncAnimation
1414

15+
# Fixing random state for reproducibility
16+
np.random.seed(19680801)
17+
1518

1619
# Create new Figure and an Axes which fills it.
1720
fig = plt.figure(figsize=(7, 7))

examples/animation/random_data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
import matplotlib.pyplot as plt
1212
import matplotlib.animation as animation
1313

14+
# Fixing random state for reproducibility
15+
np.random.seed(19680801)
16+
17+
1418
fig, ax = plt.subplots()
1519
line, = ax.plot(np.random.rand(10))
1620
ax.set_ylim(0, 1)

examples/animation/simple_3danim.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import mpl_toolkits.mplot3d.axes3d as p3
1111
import matplotlib.animation as animation
1212

13+
# Fixing random state for reproducibility
14+
np.random.seed(19680801)
15+
1316

1417
def Gen_RandLine(length, dims=2):
1518
"""

examples/animation/strip_chart_demo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def emitter(p=0.03):
4747
else:
4848
yield np.random.rand(1)
4949

50+
# Fixing random state for reproducibility
51+
np.random.seed(19680801)
52+
53+
5054
fig, ax = plt.subplots()
5155
scope = Scope(ax)
5256

examples/animation/unchained.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
import matplotlib.pyplot as plt
1313
import matplotlib.animation as animation
1414

15+
# Fixing random state for reproducibility
16+
np.random.seed(19680801)
17+
18+
1519
# Create new Figure with black background
1620
fig = plt.figure(figsize=(8, 8), facecolor='black')
1721

0 commit comments

Comments
 (0)