diff --git a/.prepare-commit-msg.py b/.prepare-commit-msg.py index 97a9b21ac..198911e21 100755 --- a/.prepare-commit-msg.py +++ b/.prepare-commit-msg.py @@ -30,18 +30,20 @@ # e.g. for a branch named 'issue-123', the commit message will start with # '[#123]' # If you wish to use a diferent prefix on branch names, change it here. -issue_prefix = 'issue-' +issue_prefix = "issue-" commit_msg_filepath = sys.argv[1] -branch = check_output( - ['git', 'symbolic-ref', '--short', 'HEAD'] -).strip().decode(encoding='UTF-8') +branch = ( + check_output(["git", "symbolic-ref", "--short", "HEAD"]) + .strip() + .decode(encoding="UTF-8") +) if branch.startswith(issue_prefix): - issue_number = re.match('%s(.*)' % issue_prefix, branch).group(1) + issue_number = re.match("%s(.*)" % issue_prefix, branch).group(1) print("prepare-commit-msg: Prepending [#%s] to commit message" % issue_number) - with open(commit_msg_filepath, 'r+') as f: + with open(commit_msg_filepath, "r+") as f: content = f.read() f.seek(0, 0) f.write("[#%s] %s" % (issue_number, content)) diff --git a/axelrod/eigen.py b/axelrod/eigen.py index 70cb1793d..1492207f0 100644 --- a/axelrod/eigen.py +++ b/axelrod/eigen.py @@ -13,24 +13,24 @@ def _normalise(nvec: numpy.ndarray) -> numpy.ndarray: """Normalises the given numpy array.""" with numpy.errstate(invalid="ignore"): - result = nvec / numpy.sqrt(numpy.dot(nvec, nvec)) + result = nvec / numpy.sqrt((nvec @ nvec)) return result def _squared_error(vector_1: numpy.ndarray, vector_2: numpy.ndarray) -> float: """Computes the squared error between two numpy arrays.""" diff = vector_1 - vector_2 - s = numpy.dot(diff, diff) + s = diff @ diff return numpy.sqrt(s) -def _power_iteration(mat: numpy.matrix, initial: numpy.ndarray) -> numpy.ndarray: +def _power_iteration(mat: numpy.array, initial: numpy.ndarray) -> numpy.ndarray: """ Generator of successive approximations. Params ------ - mat: numpy.matrix + mat: numpy.array The matrix to use for multiplication iteration initial: numpy.array, None The initial state. Will be set to numpy.array([1, 1, ...]) if None @@ -47,14 +47,14 @@ def _power_iteration(mat: numpy.matrix, initial: numpy.ndarray) -> numpy.ndarray def principal_eigenvector( - mat: numpy.matrix, maximum_iterations=1000, max_error=1e-3 + mat: numpy.array, maximum_iterations=1000, max_error=1e-3 ) -> Tuple[numpy.ndarray, float]: """ Computes the (normalised) principal eigenvector of the given matrix. Params ------ - mat: numpy.matrix + mat: numpy.array The matrix to use for multiplication iteration initial: numpy.array, None The initial state. Will be set to numpy.array([1, 1, ...]) if None @@ -71,7 +71,7 @@ def principal_eigenvector( Eigenvalue corresonding to the returned eigenvector """ - mat_ = numpy.matrix(mat) + mat_ = numpy.array(mat) size = mat_.shape[0] initial = numpy.ones(size) @@ -86,7 +86,7 @@ def principal_eigenvector( break last = vector # Compute the eigenvalue (Rayleigh quotient) - eigenvalue = numpy.dot(numpy.dot(mat_, vector), vector) / numpy.dot(vector, vector) + eigenvalue = ((mat_ @ vector) @ vector) / (vector @ vector) # Liberate the eigenvalue from numpy eigenvalue = float(eigenvalue) return vector, eigenvalue diff --git a/axelrod/graph.py b/axelrod/graph.py index fcc81ffe5..2fb44b6cf 100644 --- a/axelrod/graph.py +++ b/axelrod/graph.py @@ -115,7 +115,7 @@ def cycle(length, directed=False): ------- a Graph object for the cycle """ - edges = [(i, i+1) for i in range(length-1)] + edges = [(i, i + 1) for i in range(length - 1)] edges.append((length - 1, 0)) return Graph(edges=edges, directed=directed) @@ -136,7 +136,7 @@ def complete_graph(size, loops=True): ------- a Graph object for the complete graph """ - edges = [(i, j) for i in range(size) for j in range(i+1, size)] + edges = [(i, j) for i in range(size) for j in range(i + 1, size)] graph = Graph(edges=edges, directed=False) if loops: diff --git a/axelrod/moran.py b/axelrod/moran.py index 15b36f7b5..1f60723c7 100644 --- a/axelrod/moran.py +++ b/axelrod/moran.py @@ -156,9 +156,7 @@ def __init__( self.fitness_transformation = fitness_transformation # Map players to graph vertices self.locations = sorted(interaction_graph.vertices) - self.index = dict( - zip(sorted(interaction_graph.vertices), range(len(players))) - ) + self.index = dict(zip(sorted(interaction_graph.vertices), range(len(players)))) def set_players(self) -> None: """Copy the initial players into the first population.""" diff --git a/axelrod/strategies/human.py b/axelrod/strategies/human.py index f113f2af8..480daa5bb 100644 --- a/axelrod/strategies/human.py +++ b/axelrod/strategies/human.py @@ -22,8 +22,7 @@ def validate(self, document) -> None: text = document.text if text and text.upper() not in ["C", "D"]: - raise ValidationError(message="Action must be C or D", - cursor_position=0) + raise ValidationError(message="Action must be C or D", cursor_position=0) class Human(Player): diff --git a/axelrod/tests/unit/test_eigen.py b/axelrod/tests/unit/test_eigen.py index 1857ea6a9..0360a52e1 100644 --- a/axelrod/tests/unit/test_eigen.py +++ b/axelrod/tests/unit/test_eigen.py @@ -16,26 +16,28 @@ def test_identity_matrices(self): assert_array_almost_equal(evector, _normalise(numpy.ones(size))) def test_2x2_matrix(self): - mat = [[2, 1], [1, 2]] + mat = numpy.array([[2, 1], [1, 2]]) evector, evalue = principal_eigenvector(mat) self.assertAlmostEqual(evalue, 3) assert_array_almost_equal(evector, numpy.dot(mat, evector) / evalue) - assert_array_almost_equal(evector, _normalise([1, 1])) + assert_array_almost_equal(evector, _normalise(numpy.array([1, 1]))) def test_3x3_matrix(self): - mat = [[1, 2, 0], [-2, 1, 2], [1, 3, 1]] + mat = numpy.array([[1, 2, 0], [-2, 1, 2], [1, 3, 1]]) evector, evalue = principal_eigenvector( mat, maximum_iterations=None, max_error=1e-10 ) self.assertAlmostEqual(evalue, 3) assert_array_almost_equal(evector, numpy.dot(mat, evector) / evalue) - assert_array_almost_equal(evector, _normalise([0.5, 0.5, 1])) + assert_array_almost_equal(evector, _normalise(numpy.array([0.5, 0.5, 1]))) def test_4x4_matrix(self): - mat = [[2, 0, 0, 0], [1, 2, 0, 0], [0, 1, 3, 0], [0, 0, 1, 3]] + mat = numpy.array([[2, 0, 0, 0], [1, 2, 0, 0], [0, 1, 3, 0], [0, 0, 1, 3]]) evector, evalue = principal_eigenvector( mat, maximum_iterations=None, max_error=1e-10 ) self.assertAlmostEqual(evalue, 3, places=3) assert_array_almost_equal(evector, numpy.dot(mat, evector) / evalue) - assert_array_almost_equal(evector, _normalise([0, 0, 0, 1]), decimal=4) + assert_array_almost_equal( + evector, _normalise(numpy.array([0, 0, 0, 1])), decimal=4 + ) diff --git a/axelrod/tests/unit/test_graph.py b/axelrod/tests/unit/test_graph.py index 3f2ee687c..f97ee0f31 100644 --- a/axelrod/tests/unit/test_graph.py +++ b/axelrod/tests/unit/test_graph.py @@ -5,7 +5,6 @@ class TestGraph(unittest.TestCase): - def assert_out_mapping(self, g, expected_out_mapping): self.assertDictEqual(g.out_mapping, expected_out_mapping) for node, out_dict in expected_out_mapping.items(): @@ -97,7 +96,6 @@ def test_add_loops_with_existing_loop_and_using_strings(self): class TestCycle(unittest.TestCase): - def test_length_1_directed(self): g = graph.cycle(1, directed=True) self.assertEqual(g.vertices, [0]) @@ -124,7 +122,7 @@ def test_length_3_directed(self): g = graph.cycle(3, directed=True) self.assertEqual(g.vertices, [0, 1, 2]) self.assertEqual(g.edges, [(0, 1), (1, 2), (2, 0)]) - + def test_length_3_undirected(self): g = graph.cycle(3, directed=False) edges = [(0, 1), (1, 0), (1, 2), (2, 1), (2, 0), (0, 2)] @@ -156,7 +154,6 @@ def test_length_4_undirected(self): class TestComplete(unittest.TestCase): - def test_size_2(self): g = graph.complete_graph(2, loops=False) self.assertEqual(g.vertices, [0, 1]) @@ -209,7 +206,7 @@ def test_size_2_with_loops(self): self.assertEqual(g.vertices, [0, 1]) self.assertEqual(g.edges, [(0, 1), (1, 0), (0, 0), (1, 1)]) self.assertEqual(g.directed, False) - + def test_size_3_with_loops(self): g = graph.complete_graph(3, loops=True) self.assertEqual(g.vertices, [0, 1, 2]) diff --git a/docs/conf.py b/docs/conf.py index d79e4d7c0..d804dd549 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,19 +18,38 @@ import mock MOCK_MODULES = [ - 'cloudpickle', 'dask', 'dask.dataframe', 'dill', 'matplotlib', - 'matplotlib.pyplot', 'matplotlib.transforms', 'mpl_toolkits.axes_grid1', - 'multiprocess', 'numpy', 'numpy.linalg', 'numpy.random', 'pandas', - 'pandas.util', 'pandas.util.decorators', 'prompt_toolkit', - 'prompt_toolkit.styles', 'prompt_toolkit.token', - 'prompt_toolkit.validation', 'scipy', 'scipy.stats', 'toolz', - 'toolz.curried', 'toolz.functoolz', 'tqdm'] + "cloudpickle", + "dask", + "dask.dataframe", + "dill", + "matplotlib", + "matplotlib.pyplot", + "matplotlib.transforms", + "mpl_toolkits.axes_grid1", + "multiprocess", + "numpy", + "numpy.linalg", + "numpy.random", + "pandas", + "pandas.util", + "pandas.util.decorators", + "prompt_toolkit", + "prompt_toolkit.styles", + "prompt_toolkit.token", + "prompt_toolkit.validation", + "scipy", + "scipy.stats", + "toolz", + "toolz.curried", + "toolz.functoolz", + "tqdm", +] for mod_name in MOCK_MODULES: sys.modules[mod_name] = mock.Mock() # Adds absolute path to axelrod module -sys.path.insert(0, os.path.abspath('../')) # Adding path to module +sys.path.insert(0, os.path.abspath("../")) # Adding path to module # Import the library (for automodule) import axelrod @@ -38,224 +57,215 @@ # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.mathjax', - 'sphinx.ext.viewcode', -] +extensions = ["sphinx.ext.autodoc", "sphinx.ext.mathjax", "sphinx.ext.viewcode"] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'Axelrod' -copyright = '2015, Vincent Knight' +project = "Axelrod" +copyright = "2015, Vincent Knight" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '0.0' +version = "0.0" # The full version, including alpha/beta/rc tags. -release = '0.0.1' +release = "0.0.1" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -on_rtd = os.environ.get('READTHEDOCS', None) == 'True' +on_rtd = os.environ.get("READTHEDOCS", None) == "True" if not on_rtd: # only import and set the theme if we're building docs locally import sphinx_rtd_theme - html_theme = 'sphinx_rtd_theme' + + html_theme = "sphinx_rtd_theme" html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -html_short_title = 'Axelrod' +html_short_title = "Axelrod" # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -html_favicon = '_static/favicon.ico' +html_favicon = "_static/favicon.ico" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. -#html_extra_path = [] +# html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'Axelroddoc' +htmlhelp_basename = "Axelroddoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'Axelrod.tex', 'Axelrod Documentation', - 'Vincent Knight', 'manual'), + ("index", "Axelrod.tex", "Axelrod Documentation", "Vincent Knight", "manual") ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'axelrod', 'Axelrod Documentation', - ['Vincent Knight'], 1) -] +man_pages = [("index", "axelrod", "Axelrod Documentation", ["Vincent Knight"], 1)] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------- @@ -264,19 +274,25 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'Axelrod', 'Axelrod Documentation', - 'Vincent Knight', 'Axelrod', 'One line description of project.', - 'Miscellaneous'), + ( + "index", + "Axelrod", + "Axelrod Documentation", + "Vincent Knight", + "Axelrod", + "One line description of project.", + "Miscellaneous", + ) ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False diff --git a/doctests.py b/doctests.py index 6a466c1d9..ab3a9cfd5 100644 --- a/doctests.py +++ b/doctests.py @@ -9,13 +9,15 @@ def load_tests(loader, tests, ignore): for root, dirs, files in os.walk("."): for f in files: if f.endswith(".rst"): - tests.addTests( - doctest.DocFileSuite(os.path.join(root, f), - optionflags=doctest.ELLIPSIS)) + tests.addTests( + doctest.DocFileSuite( + os.path.join(root, f), optionflags=doctest.ELLIPSIS + ) + ) return tests -if __name__ == '__main__': +if __name__ == "__main__": warnings.simplefilter("ignore") unittest.main() diff --git a/run_mypy.py b/run_mypy.py index acdfd6826..c7f3f487a 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -1,61 +1,65 @@ import subprocess import sys -modules = ["run_strategy_indexer.py", - "axelrod/action.py", - "axelrod/deterministic_cache.py", - "axelrod/ecosystem.py", - "axelrod/fingerprint.py", - "axelrod/game.py", - "axelrod/load_data_.py", - "axelrod/mock_player.py", - "axelrod/moran.py", - "axelrod/plot.py", - "axelrod/random_.py", - "axelrod/tournament.py", - "axelrod/strategies/adaptive.py", - "axelrod/strategies/alternator.py", - "axelrod/strategies/ann.py", - "axelrod/strategies/apavlov.py", - "axelrod/strategies/appeaser.py", - "axelrod/strategies/averagecopier.py", - "axelrod/strategies/axelrod_first.py", - "axelrod/strategies/axelrod_second.py", - "axelrod/strategies/backstabber.py", - "axelrod/strategies/better_and_better.py", - "axelrod/strategies/calculator.py", - "axelrod/strategies/cooperator.py", - "axelrod/strategies/cycler.py", - "axelrod/strategies/darwin.py", - "axelrod/strategies/defector.py", - "axelrod/strategies/forgiver.py", - "axelrod/strategies/geller.py", - "axelrod/strategies/gradualkiller.py", - "axelrod/strategies/grudger.py", - "axelrod/strategies/grumpy.py", - "axelrod/strategies/handshake.py", - "axelrod/strategies/hunter.py", - "axelrod/strategies/inverse.py", - "axelrod/strategies/mathematicalconstants.py", - "axelrod/strategies/memoryone.py", - "axelrod/strategies/memorytwo.py", - "axelrod/strategies/mindcontrol.py", - "axelrod/strategies/mindreader.py", - "axelrod/strategies/mutual.py", - "axelrod/strategies/negation.py", - "axelrod/strategies/oncebitten.py", - "axelrod/strategies/prober.py", - "axelrod/strategies/punisher.py", - "axelrod/strategies/qlearner.py", - "axelrod/strategies/rand.py", - "axelrod/strategies/titfortat.py", - "axelrod/strategies/hmm.py", - "axelrod/strategies/human.py", - "axelrod/strategies/finite_state_machines.py", - "axelrod/strategies/worse_and_worse.py"] + +modules = [ + "run_strategy_indexer.py", + "axelrod/action.py", + "axelrod/deterministic_cache.py", + "axelrod/ecosystem.py", + "axelrod/fingerprint.py", + "axelrod/game.py", + "axelrod/load_data_.py", + "axelrod/mock_player.py", + "axelrod/moran.py", + "axelrod/plot.py", + "axelrod/random_.py", + "axelrod/tournament.py", + "axelrod/strategies/adaptive.py", + "axelrod/strategies/alternator.py", + "axelrod/strategies/ann.py", + "axelrod/strategies/apavlov.py", + "axelrod/strategies/appeaser.py", + "axelrod/strategies/averagecopier.py", + "axelrod/strategies/axelrod_first.py", + "axelrod/strategies/axelrod_second.py", + "axelrod/strategies/backstabber.py", + "axelrod/strategies/better_and_better.py", + "axelrod/strategies/calculator.py", + "axelrod/strategies/cooperator.py", + "axelrod/strategies/cycler.py", + "axelrod/strategies/darwin.py", + "axelrod/strategies/defector.py", + "axelrod/strategies/forgiver.py", + "axelrod/strategies/geller.py", + "axelrod/strategies/gradualkiller.py", + "axelrod/strategies/grudger.py", + "axelrod/strategies/grumpy.py", + "axelrod/strategies/handshake.py", + "axelrod/strategies/hunter.py", + "axelrod/strategies/inverse.py", + "axelrod/strategies/mathematicalconstants.py", + "axelrod/strategies/memoryone.py", + "axelrod/strategies/memorytwo.py", + "axelrod/strategies/mindcontrol.py", + "axelrod/strategies/mindreader.py", + "axelrod/strategies/mutual.py", + "axelrod/strategies/negation.py", + "axelrod/strategies/oncebitten.py", + "axelrod/strategies/prober.py", + "axelrod/strategies/punisher.py", + "axelrod/strategies/qlearner.py", + "axelrod/strategies/rand.py", + "axelrod/strategies/titfortat.py", + "axelrod/strategies/hmm.py", + "axelrod/strategies/human.py", + "axelrod/strategies/finite_state_machines.py", + "axelrod/strategies/worse_and_worse.py", +] exit_codes = [] for module in modules: - rc = subprocess.call(["mypy", "--ignore-missing-imports", - "--follow-imports", "skip", module]) + rc = subprocess.call( + ["mypy", "--ignore-missing-imports", "--follow-imports", "skip", module] + ) exit_codes.append(rc) sys.exit(max(exit_codes)) diff --git a/run_strategy_indexer.py b/run_strategy_indexer.py index 072baede1..ae8a972a3 100644 --- a/run_strategy_indexer.py +++ b/run_strategy_indexer.py @@ -8,9 +8,12 @@ default_index_path = pathlib.Path("./docs/reference/all_strategies.rst") excluded_modules = ("_strategies", "__init__", "_filters", "human") -def check_module(module_path: pathlib.Path, - index_path: pathlib.Path=default_index_path, - excluded: tuple=excluded_modules) -> bool: + +def check_module( + module_path: pathlib.Path, + index_path: pathlib.Path = default_index_path, + excluded: tuple = excluded_modules, +) -> bool: """ Check if a module name is written in the index of strategies. @@ -39,7 +42,7 @@ def check_module(module_path: pathlib.Path, if __name__ == "__main__": - p = pathlib.Path('.') + p = pathlib.Path(".") modules = p.glob("./axelrod/strategies/*.py") exit_codes = [] diff --git a/setup.py b/setup.py index 7bc1ace32..54586051b 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup # Read in the requirements.txt file -with open('requirements.txt') as f: +with open("requirements.txt") as f: requirements = [] for library in f.read().splitlines(): if "hypothesis" not in library: # Skip: used only for dev @@ -12,28 +12,26 @@ long_description = f.read() # Read in the version number -exec(open('axelrod/version.py', 'r').read()) +exec(open("axelrod/version.py", "r").read()) setup( - name='Axelrod', + name="Axelrod", version=__version__, install_requires=requirements, - author='Vince Knight, Owen Campbell, Karol Langner, Marc Harper', - author_email=('axelrod-python@googlegroups.com'), - packages=['axelrod', 'axelrod.strategies', 'axelrod.data'], - url='http://axelrod.readthedocs.org/', - license='The MIT License (MIT)', - description='Reproduce the Axelrod iterated prisoners dilemma tournament', + author="Vince Knight, Owen Campbell, Karol Langner, Marc Harper", + author_email=("axelrod-python@googlegroups.com"), + packages=["axelrod", "axelrod.strategies", "axelrod.data"], + url="http://axelrod.readthedocs.org/", + license="The MIT License (MIT)", + description="Reproduce the Axelrod iterated prisoners dilemma tournament", long_description=long_description, - long_description_content_type='text/x-rst', + long_description_content_type="text/x-rst", include_package_data=True, - package_data={ - '': ['axelrod/data/*.csv'], - }, + package_data={"": ["axelrod/data/*.csv"]}, classifiers=[ - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3 :: Only', - ], - python_requires='>=3.5', + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3 :: Only", + ], + python_requires=">=3.5", )