Skip to content

Commit 523364f

Browse files
author
Tommy Odland
committed
Seed all rng in testing
1 parent cdc0b3c commit 523364f

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

tests/fmudesign/test_design_distributions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ def test_draw_values_pert(seed):
7979
assert np.isclose(values.mean(), 5, atol=0.55)
8080

8181

82-
def test_sample_discrete():
83-
rng = np.random.default_rng()
82+
@pytest.mark.parametrize("seed", range(100))
83+
def test_sample_discrete(seed):
84+
rng = np.random.default_rng(seed)
8485

8586
outcomes = ["foo", "bar.com"]
8687
# Test basic functionality
@@ -104,9 +105,10 @@ def test_sample_discrete():
104105
assert 15 <= foo_count <= 35 # Allow some variance due to randomness
105106

106107

107-
def test_draw_values():
108+
@pytest.mark.parametrize("seed", range(100))
109+
def test_draw_values(seed):
108110
"""Test the wrapper function for drawing values"""
109-
rng = np.random.default_rng()
111+
rng = np.random.default_rng(seed)
110112

111113
quantiles = rng.uniform(size=10)
112114

tests/forward_models/pyscal/test_pyscal.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
)
4545
def test_fm_pyscal(dframe, runargs, tmpdir):
4646
"""Parametrized test function for fm_pyscal"""
47+
random.seed(42)
48+
4749
tmpdir.chdir()
4850
dframe.to_csv("relperm-input.csv", index=False)
4951

0 commit comments

Comments
 (0)