Skip to content
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

Merged
merged 6 commits into from
Jul 18, 2016
Merged

Conversation

drvinceknight
Copy link
Member

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...

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.
@marcharper
Copy link
Member

Are we concerned that setting the same exact seed may have unexpected consequences?

@drvinceknight
Copy link
Member Author

I'm not sure I understand what you mean? As in the same seed for numpy and stdlib?

@marcharper
Copy link
Member

Yeah that's what I meant. I presume they use different generators / algorithms but I don't really know.

@drvinceknight
Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@meatballs meatballs merged commit aa06f8b into master Jul 18, 2016
@meatballs meatballs deleted the 651 branch July 18, 2016 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants