Skip to content

Commit 6c20f54

Browse files
committed
Format code with black and isort
1 parent 47d8a06 commit 6c20f54

File tree

2 files changed

+31
-42
lines changed

2 files changed

+31
-42
lines changed

axelrod/strategies/momentum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Momentum(Player):
3737
def __init__(
3838
self,
3939
alpha=0.9914655399877477, # Optimized by Genetic Algorithm. You can try to adapt it to any Env.
40-
threshold=0.9676595613724907, # This one too
40+
threshold=0.9676595613724907, # This one too
4141
) -> None:
4242
super().__init__()
4343
self.alpha = alpha
Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import axelrod as axl
22
from axelrod import Action
3-
from axelrod.tests.strategies.test_player import TestPlayer
43
from axelrod.strategies.momentum import Momentum
4+
from axelrod.tests.strategies.test_player import TestPlayer
55

66
C, D = Action.C, Action.D
77

8+
89
class TestMomentum(TestPlayer):
910
name = "Momentum"
1011
player = Momentum
@@ -32,68 +33,56 @@ def test_strategy(self):
3233
self.versus_test(
3334
axl.MockPlayer(actions=[C]),
3435
expected_actions=actions,
35-
init_kwargs={"alpha": 0.5,
36-
"threshold": 0.5
37-
},
38-
attrs={"momentum": 1.0}
36+
init_kwargs={"alpha": 0.5, "threshold": 0.5},
37+
attrs={"momentum": 1.0},
3938
)
40-
39+
4140
actions = [(C, D), (C, D), (D, D)]
4241
self.versus_test(
4342
axl.MockPlayer(actions=[D]),
4443
expected_actions=actions,
45-
init_kwargs={"alpha": 0.5,
46-
"threshold": 0.5
47-
},
48-
attrs={"momentum": 0.25}
44+
init_kwargs={"alpha": 0.5, "threshold": 0.5},
45+
attrs={"momentum": 0.25},
4946
)
50-
47+
5148
def test_vs_alternator(self):
5249
actions = [(C, C), (C, D), (C, C), (C, D), (D, C)]
53-
self.versus_test(axl.Alternator(),
54-
expected_actions=actions,
55-
init_kwargs={"alpha": 0.5,
56-
"threshold": 0.5
57-
},
50+
self.versus_test(
51+
axl.Alternator(),
52+
expected_actions=actions,
53+
init_kwargs={"alpha": 0.5, "threshold": 0.5},
5854
)
5955

6056
def test_vs_cooperator(self):
6157
actions = [(C, C), (C, C), (C, C), (C, C), (C, C)]
62-
self.versus_test(axl.Cooperator(),
63-
expected_actions=actions,
64-
init_kwargs={"alpha": 0.5,
65-
"threshold": 0.5
66-
},
58+
self.versus_test(
59+
axl.Cooperator(),
60+
expected_actions=actions,
61+
init_kwargs={"alpha": 0.5, "threshold": 0.5},
6762
)
6863

6964
def test_vs_defector(self):
7065
actions = [(C, D), (C, D), (D, D), (D, D), (D, D)]
71-
self.versus_test(axl.Defector(),
72-
expected_actions=actions,
73-
init_kwargs={"alpha": 0.5,
74-
"threshold": 0.5
75-
},
66+
self.versus_test(
67+
axl.Defector(),
68+
expected_actions=actions,
69+
init_kwargs={"alpha": 0.5, "threshold": 0.5},
7670
)
7771

7872
def test_vs_random(self):
79-
# We can also test against random strategies
8073
actions = [(C, D), (C, C), (C, C), (C, D), (D, D)]
81-
self.versus_test(axl.Random(),
82-
expected_actions=actions,
83-
seed=17,
84-
init_kwargs={"alpha": 0.5,
85-
"threshold": 0.5
86-
},
74+
self.versus_test(
75+
axl.Random(),
76+
expected_actions=actions,
77+
seed=17,
78+
init_kwargs={"alpha": 0.5, "threshold": 0.5},
8779
)
8880

8981
def test_vs_random2(self):
9082
actions = [(C, C), (C, C), (C, C), (C, C)]
91-
self.versus_test(axl.Random(),
92-
expected_actions=actions,
93-
seed=3,
94-
init_kwargs={"alpha": 0.5,
95-
"threshold": 0.5
96-
},
83+
self.versus_test(
84+
axl.Random(),
85+
expected_actions=actions,
86+
seed=3,
87+
init_kwargs={"alpha": 0.5, "threshold": 0.5},
9788
)
98-
99-

0 commit comments

Comments
 (0)