Skip to content

Commit

Permalink
Write a new documentation page with branch info (#1367)
Browse files Browse the repository at this point in the history
* 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..
  • Loading branch information
drvinceknight committed Sep 9, 2020
1 parent c0d7752 commit 7cbe2d7
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
17 changes: 13 additions & 4 deletions axelrod/tests/unit/test_tournament.py
Expand Up @@ -750,13 +750,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(
Expand All @@ -776,9 +782,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)]
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/contributing/guidelines.rst
Expand Up @@ -23,7 +23,7 @@ The project follows the following guidelines:
from `Chris Beams <https://chris.beams.io/posts/git-commit/>`_
5. Testing: the project uses the `unittest
<https://docs.python.org/2/library/unittest.html>`_ 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
Expand Down
1 change: 1 addition & 0 deletions docs/tutorials/contributing/index.rst
Expand Up @@ -10,6 +10,7 @@ Contents:
:maxdepth: 2

guidelines.rst
setting_up_the_environment.rst
strategy/index.rst
library/index.rst
running_tests.rst
13 changes: 0 additions & 13 deletions docs/tutorials/contributing/running_tests.rst
Expand Up @@ -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::
Expand Down Expand Up @@ -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
<https://travis-ci.org/>`_, so all tests will be run automatically when opening
a pull request. You can see the latest build status `here
<https://travis-ci.org/Axelrod-Python/Axelrod>`_.
38 changes: 38 additions & 0 deletions docs/tutorials/contributing/setting_up_the_environment.rst
@@ -0,0 +1,38 @@
Setting up the environment
==========================

Installing all dependencies
---------------------------

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

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`

0 comments on commit 7cbe2d7

Please sign in to comment.