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

Add type hints to tournament #935

Merged
merged 9 commits into from
Mar 27, 2017

Conversation

areebahmed04
Copy link
Member

@areebahmed04 areebahmed04 commented Mar 26, 2017

Unsure about edges, chunk, results.

Error when adding type hints to setup_output() in line 60.
def setup_output(self, filename=None, in_memory=False):

@souravsingh
Copy link
Contributor

@areebahmed04 There are failures in the tests. Take a look here- https://travis-ci.org/Axelrod-Python/Axelrod/jobs/215282242#L500

@souravsingh
Copy link
Contributor

Please let us know if you need help

@areebahmed04
Copy link
Member Author

@souravsingh How can i check for errors before push?
python setup.py develop and mypy --ignore-missing-imports --follow-imports skip axelrod/tournament.py works fine.

@drvinceknight
Copy link
Member

@souravsingh How can i check for errors before push?

The error you are getting is in the unit tests. There is information on running the tests here: http://axelrod.readthedocs.io/en/latest/tutorials/contributing/index.html

In this instance this line:

from .result_set import ResultSetFromFile, ResultSet, BigResultSet

Is importing BigResultSet but that's not a class that exists so when you run the unit tests:

$python -m unittest axelrod.tests.unit.test_resultset

You get the following error:

======================================================================
ERROR: axelrod (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: axelrod
Traceback (most recent call last):
  File "/opt/python/3.6.0/lib/python3.6/unittest/loader.py", line 462, in _find_test_path
    package = self._get_module_from_name(name)
  File "/opt/python/3.6.0/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
    __import__(name)
  File "/home/travis/build/Axelrod-Python/Axelrod/axelrod/__init__.py", line 22, in <module>
    from .tournament import (
  File "/home/travis/build/Axelrod-Python/Axelrod/axelrod/tournament.py", line 15, in <module>
    from .result_set import ResultSetFromFile, ResultSet, BigResultSet
ImportError: cannot import name 'BigResultSet'

So you need to use ResultSet (which should work fine for that function as ResultSetFromFile inherits from ResultSet).

@areebahmed04
Copy link
Member Author

Test was successful locally but getting this error on Travis.

ERROR: test_decorator_with_stochastic_strategies (axelrod.tests.unit.test_property.TestProbEndSpatialTournament)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "/home/travis/build/Axelrod-Python/Axelrod/axelrod/tests/unit/test_property.py", line 236, in test_decorator_with_stochastic_strategies

    max_size=3))

  File "/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/hypothesis/core.py", line 439, in wrapped_test

    HealthCheck.too_slow,

  File "/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/hypothesis/core.py", line 307, in fail_health_check

    raise FailedHealthCheck(message)

hypothesis.errors.FailedHealthCheck: Data generation is extremely slow: Only produced 10 valid examples in 1.03 seconds (0 invalid ones and 0 exceeded maximum size). Try decreasing size of the data you're generating (with e.g.average_size or max_leaves parameters).

@souravsingh
Copy link
Contributor

It is a sporadic failure. It should be fixed by a restart @drvinceknight

@drvinceknight
Copy link
Member

It is a sporadic failure. It should be fixed by a restart @drvinceknight

Yup, I've restarted that, I'm going to see if I can fix that particular error so that it stops happening.

drvinceknight added a commit that referenced this pull request Mar 27, 2017
This should hopefully stop sporadic failures on travis (due to
timeouts) - mentioned on #935
drvinceknight added a commit that referenced this pull request Mar 27, 2017
This should hopefully stop sporadic failures on travis (due to
timeouts) - mentioned on #935
@drvinceknight
Copy link
Member

Thanks for this @areebahmed04, could you add axelrod/tournament.py to the modules list in run_mypy.py, this will make sure that mypy runs on travis too. 👍

name='axelrod', game=None, turns=200, repetitions=10,
noise=0, with_morality=True):
def __init__(self, players: List[Player], match_generator: MatchGenerator=RoundRobinMatches,
name: str='axelrod', game: Game=None, turns: int=200, repetitions:int =10,
Copy link
Member

Choose a reason for hiding this comment

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

Minor typo: missing space in repetitions:int=10

@meatballs
Copy link
Member

@areebahmed04 I've marked this as ready to merge. We have a policy where at least 2 of the core team have to approve a PR before it's merged. One of the others will be along when they are able.

@drvinceknight drvinceknight merged commit 2f8f4c3 into Axelrod-Python:master Mar 27, 2017
@areebahmed04
Copy link
Member Author

@drvinceknight @souravsingh @meatballs Thanks for the help! This was my first PR.

@drvinceknight
Copy link
Member

Fantastic! Welcome to the project and we will look forward to your next PR.

marcharper pushed a commit that referenced this pull request Mar 28, 2017
This should hopefully stop sporadic failures on travis (due to
timeouts) - mentioned on #935
@areebahmed04 areebahmed04 deleted the typeHint808 branch April 6, 2017 14:01
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

4 participants