Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd0c99a

Browse files
committed
Use fixed random seed for tests using bootstrapping.
Bootstrapping requires random sampling, so it needs a fixed seed to ensure test consistency.
1 parent 0f2e853 commit cd0c99a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,6 +1815,9 @@ def test_bxp_bad_positions():
18151815
tol=1,
18161816
style='default')
18171817
def test_boxplot():
1818+
# Randomness used for bootstrapping.
1819+
np.random.seed(937)
1820+
18181821
x = np.linspace(-7, 7, 140)
18191822
x = np.hstack([-25, x, 25])
18201823
fig, ax = plt.subplots()
@@ -1833,6 +1836,9 @@ def test_boxplot():
18331836
remove_text=True, extensions=['png'],
18341837
style='default')
18351838
def test_boxplot_sym2():
1839+
# Randomness used for bootstrapping.
1840+
np.random.seed(937)
1841+
18361842
x = np.linspace(-7, 7, 140)
18371843
x = np.hstack([-25, x, 25])
18381844
fig, [ax1, ax2] = plt.subplots(1, 2)
@@ -1864,6 +1870,9 @@ def test_boxplot_sym():
18641870
style='default'
18651871
)
18661872
def test_boxplot_autorange_whiskers():
1873+
# Randomness used for bootstrapping.
1874+
np.random.seed(937)
1875+
18671876
x = np.ones(140)
18681877
x = np.hstack([0, x, 2])
18691878

@@ -1886,6 +1895,9 @@ def _rc_test_bxp_helper(ax, rc_dict):
18861895
savefig_kwarg={'dpi': 100}, remove_text=True,
18871896
tol=1, style='default')
18881897
def test_boxplot_rc_parameters():
1898+
# Randomness used for bootstrapping.
1899+
np.random.seed(937)
1900+
18891901
fig, ax = plt.subplots(3)
18901902

18911903
rc_axis0 = {
@@ -1948,6 +1960,9 @@ def test_boxplot_rc_parameters():
19481960
remove_text=True, extensions=['png'],
19491961
savefig_kwarg={'dpi': 40}, style='default')
19501962
def test_boxplot_with_CIarray():
1963+
# Randomness used for bootstrapping.
1964+
np.random.seed(937)
1965+
19511966
x = np.linspace(-7, 7, 140)
19521967
x = np.hstack([-25, x, 25])
19531968
fig = plt.figure()

0 commit comments

Comments
 (0)