-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
651 - Tests for random seeding and a random seeding function #653
Conversation
Note: we need to have set in a seed in both stdlib and numpy. The weird upper value in the hypothesis test is based on an upper bound on the seed function.
Are we concerned that setting the same exact seed may have unexpected consequences? |
I'm not sure I understand what you mean? As in the same seed for numpy and stdlib? |
Yeah that's what I meant. I presume they use different generators / algorithms but I don't really know. |
Yeah I believe they're two completely different generators (which is why you need to set both seeds). I don't believe they are any unintended circumstances but just in case I've just added 7ee1d83 which adds 2 further integration tests that checks not that two matches repeat but that actual tournaments repeat as well. |
@@ -16,3 +17,18 @@ def test_return_values(self): | |||
self.assertEqual(random_choice(), C) | |||
random.seed(2) | |||
self.assertEqual(random_choice(), D) | |||
|
|||
def test_set_seed(self): | |||
"""Test that numpy and stdlib random seed is set by set seed helper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_seed
would make this sentence less confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good call.
Before I change that: what do you think about the name of the function: is set_seed
the right way to go? Should it actually just be seed
?
So there's random.seed
, numpy.random.seed
and then equivalently axelrod.seed
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's a good idea :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Closes #651
Firstly this adds a test to
integration/test_matches
. Simply checks that if two stochastic matches are played with the same seed they give the same result.Note that both the numpy and stdlib seed need to be set.
Have also added a function that sets both of those:
axelrod.set_seed
just to make it 'less easy' to only set one of the seeds...