Skip to content

Commit 7cbe2d7

Browse files
Write a new documentation page with branch info (#1367)
* Write a new documentation page with branch info This is related to #1352. Once this PR is merged we should: - Change github default branch to `dev` - Delete `master` - Confirm that read the docs is looking at `release` Am I missing anything? We should also remove the release process information from the wiki (assuming we're happy with what I've written here). Finally, once #1360 is done we should make sure we update the docs with the relevant information. * Remove ambiguous `very`. * Remove hypothesis version specification in docs. This is actually no longer correct since #1288 * Test properties not affected by floating point error This build found a particular failing example of `TestTournament.test_seeding_equality` https://github.com/Axelrod-Python/Axelrod/pull/1368/checks?check_run_id=975415322 Upon closer investigation it looks like that was not due to seeding but due to the floating point error of some calculations made by the result set. I investigated using: ``` import axelrod as axl import numpy as np seed = 2 repetitions = 10 rng = axl.RandomGenerator(seed=seed) players = [axl.Random(rng.random()) for _ in range(8)] tournament1 = axl.Tournament( players=players, turns=10, repetitions=repetitions, seed=seed ) tournament2 = axl.Tournament( players=players, turns=10, repetitions=repetitions, seed=seed ) for _ in range(4): results1 = tournament1.play(processes=2, progress_bar=False) results2 = tournament2.play(processes=2, progress_bar=False) assert results1.wins == results2.wins assert results1.match_lengths == results2.match_lengths assert results1.scores == results2.scores assert np.allclose(results1.normalised_scores, results2.normalised_scores) assert np.allclose(results1.ranking, results2.ranking) assert results1.ranked_names == results2.ranked_names assert results1.payoffs == results2.payoffs assert results1.payoff_matrix == results2.payoff_matrix assert np.allclose(results1.payoff_stddevs, results2.payoff_stddevs) assert results1.score_diffs == results2.score_diffs assert results1.payoff_diffs_means == results2.payoff_diffs_means assert results1.cooperation == results2.cooperation assert results1.normalised_cooperation == results2.normalised_cooperation assert results1.vengeful_cooperation == results2.vengeful_cooperation assert results1.cooperating_rating == results2.cooperating_rating assert results1.good_partner_matrix == results2.good_partner_matrix assert results1.good_partner_rating == results2.good_partner_rating assert np.allclose(results1.eigenmoses_rating, results2.eigenmoses_rating) assert np.allclose(results1.eigenjesus_rating, results2.eigenjesus_rating) ``` Note I'm using `np.isclose` for some properties. In this commit: - I add the specific seed for which the error was found as a hypothesis example (`seed=2`). - Replace the `results1 == results2` check with just a check of some properties (from which the others are essentially calculated). - Added `progress_bar=False` * Add instructions for using venv. * s/requirements/requirements.txt * Spell requirements correctly..
1 parent c0d7752 commit 7cbe2d7

File tree

5 files changed

+53
-18
lines changed

5 files changed

+53
-18
lines changed

axelrod/tests/unit/test_tournament.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -750,13 +750,19 @@ def test_write_to_csv_without_results(self):
750750
self.assertTrue(df.equals(expected_df))
751751

752752
@given(seed=integers(min_value=1, max_value=4294967295))
753+
@example(seed=2)
753754
@settings(max_examples=5, deadline=None)
754755
def test_seeding_equality(self, seed):
755756
"""Tests that a tournament with a given seed will return the
756757
same results each time. This specifically checks when running using
757758
multiple cores so as to confirm that
758759
https://github.com/Axelrod-Python/Axelrod/issues/1277
759-
is fixed."""
760+
is fixed.
761+
762+
Note that the final asserts test only specific properties of the results
763+
sets and not the entire result sets as some floating point errors can
764+
emerge.
765+
"""
760766
rng = axl.RandomGenerator(seed=seed)
761767
players = [axl.Random(rng.random()) for _ in range(8)]
762768
tournament1 = axl.Tournament(
@@ -776,9 +782,12 @@ def test_seeding_equality(self, seed):
776782
seed=seed,
777783
)
778784
for _ in range(4):
779-
results1 = tournament1.play(processes=2)
780-
results2 = tournament2.play(processes=2)
781-
self.assertEqual(results1.ranked_names, results2.ranked_names)
785+
results1 = tournament1.play(processes=2, progress_bar=False)
786+
results2 = tournament2.play(processes=2, progress_bar=False)
787+
self.assertEqual(results1.wins, results2.wins)
788+
self.assertEqual(results1.match_lengths, results2.match_lengths)
789+
self.assertEqual(results1.scores, results2.scores)
790+
self.assertEqual(results1.cooperation, results2.cooperation)
782791

783792
def test_seeding_inequality(self):
784793
players = [axl.Random(0.4), axl.Random(0.6)]

docs/tutorials/contributing/guidelines.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The project follows the following guidelines:
2323
from `Chris Beams <https://chris.beams.io/posts/git-commit/>`_
2424
5. Testing: the project uses the `unittest
2525
<https://docs.python.org/2/library/unittest.html>`_ library and has a nice
26-
testing suite that makes some things very easy to write tests for. Please try
26+
testing suite that makes some things easy to write tests for. Please try
2727
to increase the test coverage on pull requests.
2828
6. Merging pull-requests: We require two of the (currently three) core-team
2929
maintainers to merge. Opening a PR for early

docs/tutorials/contributing/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Contents:
1010
:maxdepth: 2
1111

1212
guidelines.rst
13+
setting_up_the_environment.rst
1314
strategy/index.rst
1415
library/index.rst
1516
running_tests.rst

docs/tutorials/contributing/running_tests.rst

-13
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ Running tests
44
Basic test runners
55
------------------
66

7-
Before running tests, you should have hypothesis 3.2 installed::
8-
9-
$ pip install hypothesis==3.2
10-
117
The project has an extensive test suite which is run each time a new
128
contribution is made to the repository. If you want to check that all the tests
139
pass before you submit a pull request you can run the tests yourself::
@@ -73,12 +69,3 @@ You can also run the type checker on a given file. For example, to run the type
7369
checker on the Grudger strategy::
7470

7571
$ mypy --ignore-missing-imports --follow-imports skip axelrod/strategies/grudger.py
76-
77-
78-
Continuous integration
79-
======================
80-
81-
This project is being taken care of by `travis-ci
82-
<https://travis-ci.org/>`_, so all tests will be run automatically when opening
83-
a pull request. You can see the latest build status `here
84-
<https://travis-ci.org/Axelrod-Python/Axelrod>`_.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Setting up the environment
2+
==========================
3+
4+
Installing all dependencies
5+
---------------------------
6+
7+
All dependencies can be installed by running::
8+
9+
$ pip install -r requirements.txt
10+
11+
It is recommended to do this using a virtual environment tool of your choice.
12+
13+
For example, when using the virtual environment library :code:`venv`::
14+
15+
$ python -m venv axelrod_development
16+
$ source axelrod_development/bin/activate
17+
$ pip install -r requirements.txt
18+
19+
The git workflow
20+
----------------
21+
22+
There are two important branches in this repository:
23+
24+
- :code:`dev`: The most up to date branch with no failing tests.
25+
This is the default branch on github.
26+
- :code:`release`: The latest release.
27+
28+
When working on a new contribution branch from the latest :code:`dev` branch and
29+
open a Pull Request on github from your branch to the :code:`dev` branch.
30+
31+
The procedure for a new release (this is carried out by one of core maintainers):
32+
33+
1. Create a Pull Request from :code:`dev` to :code:`release` which should
34+
include an update to :code:`axelrod/version.py` and :code:`CHANGES.md`
35+
2. Create a git tag.
36+
3. Push to github.
37+
4. Create a release on github.
38+
5. Push to PyPi: :code:`python setup.py sdist bdist_wheel upload`

0 commit comments

Comments
 (0)