From 76cefeb564d1756c27716b23aad013fffb3b3748 Mon Sep 17 00:00:00 2001 From: Vince Knight Date: Wed, 12 Aug 2020 11:08:15 +0100 Subject: [PATCH 1/7] 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. --- docs/tutorials/contributing/index.rst | 1 + .../setting_up_the_environment.rst | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 docs/tutorials/contributing/setting_up_the_environment.rst diff --git a/docs/tutorials/contributing/index.rst b/docs/tutorials/contributing/index.rst index 9460afdbf..6a3555ad7 100644 --- a/docs/tutorials/contributing/index.rst +++ b/docs/tutorials/contributing/index.rst @@ -10,6 +10,7 @@ Contents: :maxdepth: 2 guidelines.rst + setting_up_the_environment.rst strategy/index.rst library/index.rst running_tests.rst diff --git a/docs/tutorials/contributing/setting_up_the_environment.rst b/docs/tutorials/contributing/setting_up_the_environment.rst new file mode 100644 index 000000000..47f08b22c --- /dev/null +++ b/docs/tutorials/contributing/setting_up_the_environment.rst @@ -0,0 +1,32 @@ +Setting up the environment +========================== + +Installing all dependencies +--------------------------- + +All testing dependencies can be installed by running:: + + $ pip install -r requirements.txt + +It is recommended to do this using a virtual environment tool of your choice. + +The git workflow +---------------- + +There are two important branches in this repository: + +- :code:`dev`: The most up to date branch with no failing tests. + This is the default branch on github. +- :code:`release`: The latest release. + +When working on a new contribution branch from the latest :code:`dev` branch and +open a Pull Request on github from your branch to the :code:`dev` branch. + +The procedure for a new release (this is carried out by one of core maintainers): + +1. Create a Pull Request from :code:`dev` to :code:`release` which should + include an update to :code:`axelrod/version.py` and :code:`CHANGES.md` +2. Create a git tag. +3. Push to github. +4. Create a release on github. +5. Push to PyPi: :code:`python setup.py sdist bdist_wheel upload` From 5cd6f3adbd68f5e77e7b657894a1fbf85ce8816f Mon Sep 17 00:00:00 2001 From: Vince Knight Date: Wed, 12 Aug 2020 11:12:31 +0100 Subject: [PATCH 2/7] Remove ambiguous `very`. --- docs/tutorials/contributing/guidelines.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/contributing/guidelines.rst b/docs/tutorials/contributing/guidelines.rst index 42fc0923d..6dec5f8c2 100644 --- a/docs/tutorials/contributing/guidelines.rst +++ b/docs/tutorials/contributing/guidelines.rst @@ -20,7 +20,7 @@ The project follows the following guidelines: from `Chris Beams `_ 5. Testing: the project uses the `unittest `_ library and has a nice - testing suite that makes some things very easy to write tests for. Please try + testing suite that makes some things easy to write tests for. Please try to increase the test coverage on pull requests. 6. Merging pull-requests: We require two of the (currently three) core-team maintainers to merge. Opening a PR for early From 917eead4e976a8c90e7281bca7d919aa652ec5f0 Mon Sep 17 00:00:00 2001 From: Vince Knight Date: Wed, 12 Aug 2020 11:12:44 +0100 Subject: [PATCH 3/7] Remove hypothesis version specification in docs. This is actually no longer correct since #1288 --- docs/tutorials/contributing/running_tests.rst | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/docs/tutorials/contributing/running_tests.rst b/docs/tutorials/contributing/running_tests.rst index 3afcde7f6..f3ca6d961 100644 --- a/docs/tutorials/contributing/running_tests.rst +++ b/docs/tutorials/contributing/running_tests.rst @@ -4,10 +4,6 @@ Running tests Basic test runners ------------------ -Before running tests, you should have hypothesis 3.2 installed:: - - $ pip install hypothesis==3.2 - The project has an extensive test suite which is run each time a new contribution is made to the repository. If you want to check that all the tests 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 checker on the Grudger strategy:: $ mypy --ignore-missing-imports --follow-imports skip axelrod/strategies/grudger.py - - -Continuous integration -====================== - -This project is being taken care of by `travis-ci -`_, so all tests will be run automatically when opening -a pull request. You can see the latest build status `here -`_. From 3f60d5d404369c361284fbada262243c3d815b3d Mon Sep 17 00:00:00 2001 From: Vince Knight Date: Wed, 12 Aug 2020 12:20:04 +0100 Subject: [PATCH 4/7] 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` --- axelrod/tests/unit/test_tournament.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/axelrod/tests/unit/test_tournament.py b/axelrod/tests/unit/test_tournament.py index f8cca4bb4..7f0e20d65 100644 --- a/axelrod/tests/unit/test_tournament.py +++ b/axelrod/tests/unit/test_tournament.py @@ -732,13 +732,19 @@ def test_write_to_csv_without_results(self): self.assertTrue(df.equals(expected_df)) @given(seed=integers(min_value=1, max_value=4294967295)) + @example(seed=2) @settings(max_examples=5, deadline=None) def test_seeding_equality(self, seed): """Tests that a tournament with a given seed will return the same results each time. This specifically checks when running using multiple cores so as to confirm that https://github.com/Axelrod-Python/Axelrod/issues/1277 - is fixed.""" + is fixed. + + Note that the final asserts test only specific properties of the results + sets and not the entire result sets as some floating point errors can + emerge. + """ rng = axl.RandomGenerator(seed=seed) players = [axl.Random(rng.random()) for _ in range(8)] tournament1 = axl.Tournament( @@ -758,9 +764,12 @@ def test_seeding_equality(self, seed): seed=seed ) for _ in range(4): - results1 = tournament1.play(processes=2) - results2 = tournament2.play(processes=2) - self.assertEqual(results1.ranked_names, results2.ranked_names) + results1 = tournament1.play(processes=2, progress_bar=False) + results2 = tournament2.play(processes=2, progress_bar=False) + self.assertEqual(results1.wins, results2.wins) + self.assertEqual(results1.match_lengths, results2.match_lengths) + self.assertEqual(results1.scores, results2.scores) + self.assertEqual(results1.cooperation, results2.cooperation) def test_seeding_inequality(self): players = [axl.Random(0.4), axl.Random(0.6)] From 95e29050ec772a27e93b5801b6b8d6a75a408448 Mon Sep 17 00:00:00 2001 From: Vince Knight Date: Wed, 12 Aug 2020 16:43:27 +0100 Subject: [PATCH 5/7] Add instructions for using venv. --- .../tutorials/contributing/setting_up_the_environment.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/contributing/setting_up_the_environment.rst b/docs/tutorials/contributing/setting_up_the_environment.rst index 47f08b22c..e5737ea69 100644 --- a/docs/tutorials/contributing/setting_up_the_environment.rst +++ b/docs/tutorials/contributing/setting_up_the_environment.rst @@ -4,12 +4,18 @@ Setting up the environment Installing all dependencies --------------------------- -All testing dependencies can be installed by running:: +All dependencies can be installed by running:: $ pip install -r requirements.txt It is recommended to do this using a virtual environment tool of your choice. +For example, when using the virtual environment library :code:`venv`:: + + $ python -m venv axelrod_development + $ source axelrod_development/bin/activate + $ pip install -r requrirements + The git workflow ---------------- From dd07cdc343654d398439bcafb2b3c7744771f4ad Mon Sep 17 00:00:00 2001 From: Vince Knight Date: Wed, 12 Aug 2020 16:51:56 +0100 Subject: [PATCH 6/7] s/requirements/requirements.txt --- docs/tutorials/contributing/setting_up_the_environment.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/contributing/setting_up_the_environment.rst b/docs/tutorials/contributing/setting_up_the_environment.rst index e5737ea69..e97485e60 100644 --- a/docs/tutorials/contributing/setting_up_the_environment.rst +++ b/docs/tutorials/contributing/setting_up_the_environment.rst @@ -14,7 +14,7 @@ For example, when using the virtual environment library :code:`venv`:: $ python -m venv axelrod_development $ source axelrod_development/bin/activate - $ pip install -r requrirements + $ pip install -r requrirements.txt The git workflow ---------------- From f88bfc6fabbc38d8c30eb184db1719d662c8b768 Mon Sep 17 00:00:00 2001 From: Vince Knight Date: Wed, 12 Aug 2020 17:41:35 +0100 Subject: [PATCH 7/7] Spell requirements correctly.. --- docs/tutorials/contributing/setting_up_the_environment.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/contributing/setting_up_the_environment.rst b/docs/tutorials/contributing/setting_up_the_environment.rst index e97485e60..2d6be2f86 100644 --- a/docs/tutorials/contributing/setting_up_the_environment.rst +++ b/docs/tutorials/contributing/setting_up_the_environment.rst @@ -14,7 +14,7 @@ For example, when using the virtual environment library :code:`venv`:: $ python -m venv axelrod_development $ source axelrod_development/bin/activate - $ pip install -r requrirements.txt + $ pip install -r requirements.txt The git workflow ----------------