Skip to content

Commit 603c0fb

Browse files
committed
Add a better doctest for setting random seed.
The previous doctests were checking particular results. When new strategies where added to the library and/or other changes were made, this could offset the random seed so the exact result would not necessarily be the same. This is the actual check we want: it checks that the results don't change. We don't care what they actually are.
1 parent 33a595d commit 603c0fb

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

docs/tutorials/advanced/setting_a_seed.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ set. To do this we can use the `seed` function::
1111
>>> import axelrod as axl
1212
>>> players = (axl.Random(), axl.MetaMixer()) # Two stochastic strategies
1313
>>> axl.seed(0)
14-
>>> axl.Match(players, turns=3).play()
15-
[('D', 'C'), ('D', 'D'), ('C', 'C')]
14+
>>> results = axl.Match(players, turns=3).play()
1615

1716
We obtain the same results is it is played with the same seed::
1817

1918
>>> axl.seed(0)
20-
>>> axl.Match(players, turns=3).play()
21-
[('D', 'C'), ('D', 'D'), ('C', 'C')]
19+
>>> results == axl.Match(players, turns=3).play()
20+
True
2221

2322
Note that this is equivalent to::
2423

@@ -27,9 +26,8 @@ Note that this is equivalent to::
2726
>>> players = (axl.Random(), axl.MetaMixer())
2827
>>> random.seed(0)
2928
>>> numpy.random.seed(0)
30-
>>> axl.Match(players, turns=3).play()
31-
[('D', 'C'), ('D', 'D'), ('C', 'C')]
29+
>>> results = axl.Match(players, turns=3).play()
3230
>>> numpy.random.seed(0)
3331
>>> random.seed(0)
34-
>>> axl.Match(players, turns=3).play()
35-
[('D', 'C'), ('D', 'D'), ('C', 'C')]
32+
>>> results == axl.Match(players, turns=3).play()
33+
True

0 commit comments

Comments
 (0)