Skip to content

Commit 9838f84

Browse files
Move to pyproject.toml. (#1440)
* Move to pyproject.toml. This uses hatch. Note I've removed the human player. I don't believe we ever use it. If we want to we can add it back in. * Bump version number.
1 parent 95052da commit 9838f84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+328
-564
lines changed

.github/workflows/config.yml

-76
This file was deleted.

.github/workflows/tests.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
max-parallel: 4
10+
matrix:
11+
os: [ubuntu-latest, macOS-latest, windows-latest]
12+
python-version: ["3.11", "3.12"]
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
21+
- name: update pip
22+
run: |
23+
python -m pip install --upgrade pip
24+
25+
- name: install tox
26+
run: |
27+
python -m pip install tox tox-gh-actions
28+
29+
- name: run tox
30+
run: |
31+
python -m tox

axelrod/classifier.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
)
1515

1616
import yaml
17+
1718
from axelrod.makes_use_of import makes_use_of
1819
from axelrod.player import Player
1920

axelrod/fingerprint.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
from tempfile import mkstemp
44
from typing import Any, List, Union
55

6-
import axelrod as axl
76
import dask.dataframe as dd
87
import matplotlib.pyplot as plt
98
import numpy as np
109
import tqdm
10+
from mpl_toolkits.axes_grid1 import make_axes_locatable
11+
12+
import axelrod as axl
1113
from axelrod import Player
1214
from axelrod.interaction_utils import (
1315
compute_final_score_per_turn,
1416
read_interactions_from_file,
1517
)
1618
from axelrod.strategy_transformers import DualTransformer, JossAnnTransformer
17-
from mpl_toolkits.axes_grid1 import make_axes_locatable
1819

1920
Point = namedtuple("Point", "x y")
2021

axelrod/game.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from typing import Tuple, Union
21
from enum import Enum
2+
from typing import Tuple, Union
33

44
import numpy as np
55

@@ -71,6 +71,7 @@ def get_value(x):
7171
if isinstance(x, Enum):
7272
return x.value
7373
return x
74+
7475
row, col = map(get_value, pair)
7576

7677
return (self.A[row][col], self.B[row][col])
@@ -97,7 +98,9 @@ class Game(AsymmetricGame):
9798
The numerical score attribute to all combinations of action pairs.
9899
"""
99100

100-
def __init__(self, r: Score = 3, s: Score = 0, t: Score = 5, p: Score = 1) -> None:
101+
def __init__(
102+
self, r: Score = 3, s: Score = 0, t: Score = 5, p: Score = 1
103+
) -> None:
101104
"""Create a new game object.
102105
103106
Parameters

axelrod/interaction_utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
This is used by both the Match class and the ResultSet class which analyse
88
interactions.
99
"""
10+
1011
from collections import Counter, defaultdict
1112

1213
import pandas as pd
1314
import tqdm
15+
1416
from axelrod.action import Action, str_to_actions
1517

1618
from .game import Game

axelrod/load_data_.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pathlib
2+
import pkgutil
23
from typing import Dict, List, Text, Tuple
34

4-
import pkgutil
55

66
def axl_filename(path: pathlib.Path) -> pathlib.Path:
77
"""Given a path under Axelrod/, return absolute filepath.
@@ -27,7 +27,7 @@ def load_file(filename: str, directory: str) -> List[List[str]]:
2727
path = str(pathlib.Path(directory) / filename)
2828
data_bytes = pkgutil.get_data(__name__, path)
2929
data = data_bytes.decode("UTF-8", "replace")
30-
30+
3131
rows = []
3232
for line in data.split("\n"):
3333
if line.startswith("#") or len(line) == 0:
@@ -57,7 +57,12 @@ def load_pso_tables(filename="pso_gambler.csv", directory="data"):
5757
rows = load_file(filename, directory)
5858
d = dict()
5959
for row in rows:
60-
name, a, b, c, = (
60+
(
61+
name,
62+
a,
63+
b,
64+
c,
65+
) = (
6166
str(row[0]),
6267
int(row[1]),
6368
int(row[2]),

axelrod/moran.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import matplotlib.pyplot as plt
77
import numpy as np
8+
89
from axelrod import DEFAULT_TURNS, EvolvablePlayer, Game, Player
910
from axelrod.deterministic_cache import DeterministicCache
1011
from axelrod.graph import Graph, complete_graph

axelrod/player.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Any, Dict
77

88
import numpy as np
9+
910
from axelrod import _module_random
1011
from axelrod.action import Action
1112
from axelrod.game import DefaultGame
@@ -121,7 +122,7 @@ def _post_init(self):
121122
def _post_transform(self):
122123
"""Handles post transform tasks such as further reclassifying."""
123124
# Reclassify strategy post __init__, if needed.
124-
for (reclassifier, args, kwargs) in self._reclassifiers:
125+
for reclassifier, args, kwargs in self._reclassifiers:
125126
self.classifier = reclassifier(self.classifier, *args, **kwargs)
126127

127128
def __eq__(self, other):

axelrod/plot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def _payoff_heatmap(
176176
names: namesType,
177177
title: titleType = None,
178178
ax: matplotlib.axes.SubplotBase = None,
179-
cmap: str = 'viridis'
179+
cmap: str = "viridis",
180180
) -> matplotlib.figure.Figure:
181181
"""Generic heatmap plot"""
182182

axelrod/random_.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from typing import Optional
22

33
import numpy as np
4-
from axelrod.action import Action
54
from numpy.random import RandomState
65

6+
from axelrod.action import Action
7+
78
C, D = Action.C, Action.D
89

910

axelrod/result_set.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import dask.dataframe as dd
1010
import numpy as np
1111
import tqdm
12+
1213
from axelrod.action import Action
1314

1415
from . import eigen

axelrod/strategies/_strategies.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121
# isort:skip_file
2222
"""
23+
2324
import warnings
2425

2526
from .adaptive import Adaptive
@@ -152,16 +153,6 @@
152153
from .hmm import EvolvedHMM5
153154
from .hmm import EvolvableHMMPlayer, HMMPlayer # pylint: disable=unused-import
154155

155-
try:
156-
from .human import Human # pylint: disable=unused-import
157-
except ImportError as ie: # pragma: no cover
158-
# Check that the expected module is missing and no other.
159-
if ie.name == "prompt_toolkit":
160-
warnings.warn(
161-
"Human strategy not available because python package prompt_toolkit is not available."
162-
)
163-
else:
164-
raise ie
165156
from .hunter import (
166157
AlternatorHunter,
167158
CooperatorHunter,

axelrod/strategies/adaptor.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from typing import Dict, Tuple
22

3+
from numpy import heaviside
4+
35
from axelrod.action import Action
46
from axelrod.player import Player
5-
from numpy import heaviside
67

78
C, D = Action.C, Action.D
89

axelrod/strategies/ann.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import List, Tuple
22

33
import numpy as np
4+
45
from axelrod.action import Action
56
from axelrod.evolvable_player import (
67
EvolvablePlayer,

axelrod/strategies/axelrod_first.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515

1616
from typing import Dict, List, Optional, Tuple
1717

18+
from scipy.stats import chisquare
19+
1820
from axelrod.action import Action
1921
from axelrod.player import Player
2022
from axelrod.strategy_transformers import FinalTransformer
21-
from scipy.stats import chisquare
2223

2324
from .memoryone import MemoryOnePlayer
2425

@@ -624,7 +625,6 @@ def score_history(
624625
opponent_history: List[Action],
625626
score_map: Dict[Tuple[Action, Action], int],
626627
) -> int:
627-
628628
"""Implements the Nydegger formula A = 16 a_1 + 4 a_2 + a_3"""
629629
a = 0
630630
for i, weight in [(-1, 16), (-2, 4), (-3, 1)]:

axelrod/strategies/axelrod_second.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing import List
88

99
import numpy as np
10+
1011
from axelrod.action import Action
1112
from axelrod.interaction_utils import compute_final_score
1213
from axelrod.player import Player
@@ -204,7 +205,6 @@ def strategy(self, opponent: Player) -> Action:
204205

205206

206207
class SecondByTranquilizer(Player):
207-
208208
"""
209209
Submitted to Axelrod's second tournament by Craig Feathers
210210
@@ -341,7 +341,6 @@ def __init__(self):
341341
self.dict = {C: 0, D: 1}
342342

343343
def update_state(self, opponent):
344-
345344
"""
346345
Calculates the ratio values for the one_turn_after_good_defection_ratio,
347346
two_turns_after_good_defection_ratio and the probability values,
@@ -1349,9 +1348,9 @@ def strategy(self, opponent: Player) -> Action:
13491348
if self.detect_streak(opponent.history[-1]):
13501349
return self.try_return(D, inc_parity=True)
13511350
if self.detect_parity_streak(opponent.history[-1]):
1352-
self.parity_streak[
1353-
self.parity_bit
1354-
] = 0 # Reset `parity_streak` when we hit the limit.
1351+
self.parity_streak[self.parity_bit] = (
1352+
0 # Reset `parity_streak` when we hit the limit.
1353+
)
13551354
self.parity_hits += (
13561355
1 # Keep track of how many times we hit the limit.
13571356
)

axelrod/strategies/darwin.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
indicated by their classifier). We do not recommend putting a lot of time in to
44
optimising it.
55
"""
6+
67
from typing import Optional
78

89
from axelrod.action import Action

axelrod/strategies/gambler.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
For the original see:
55
https://gist.github.com/GDKO/60c3d0fd423598f3c4e4
66
"""
7+
78
from typing import Any
89

910
from axelrod.action import Action, actions_to_str, str_to_actions

0 commit comments

Comments
 (0)