Skip to content

Commit

Permalink
add test for fixed random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
sherbold committed Jul 25, 2023
1 parent b91fad3 commit c674603
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_autorank.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,3 +797,18 @@ def test_cd_order(self):
plot_stats(res)
plot_stats(res_asc)
plt.draw()

def test_fix_random_state(self):
std = 0.15
means = [0.3, 0.3]
data = pd.DataFrame()
for i, mean in enumerate(means):
data['pop_%i' % i] = np.random.normal(mean, std, self.sample_size).clip(0, 1)

res_42_1 = autorank(data, alpha=0.05, nsamples=100, verbose=self.verbose, approach='bayesian', random_state=42)
res_42_2 = autorank(data, alpha=0.05, nsamples=100, verbose=self.verbose, approach='bayesian', random_state=42)
res_43_1 = autorank(data, alpha=0.05, nsamples=100, verbose=self.verbose, approach='bayesian', random_state=43)

self.assertTrue(res_42_1.posterior_matrix.equals(res_42_2.posterior_matrix))
self.assertFalse(res_42_1.posterior_matrix.equals(res_43_1.posterior_matrix))

0 comments on commit c674603

Please sign in to comment.