Skip to content

Commit 6cd3fd8

Browse files
committed
Fix makes_use_of
1 parent 0669a19 commit 6cd3fd8

File tree

8 files changed

+101
-48
lines changed

8 files changed

+101
-48
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ docker-compose.yml
119119
# Mypy files
120120
.mypy_cache/
121121

122+
test_outputs/classifier_test.yaml
122123
test_outputs/stochastic_tournament_0.csv
123124
test_outputs/stochastic_tournament_1.csv
124125
test_outputs/test_fingerprint.csv

axelrod/classifier.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def classify_player(self, player: Type[Player]) -> T:
8484
manipulates_state,
8585
]
8686

87+
all_classifiers_map = {c.name: c.classify_player for c in all_classifiers}
88+
8789

8890
def rebuild_classifier_table(
8991
classifiers: List[Classifier],
@@ -216,7 +218,13 @@ def try_lookup() -> Any:
216218
return player.classifier[key]
217219

218220
# Try to find the name in the all_player_dicts, read from disk.
219-
return try_lookup()
221+
lookup = try_lookup()
222+
if lookup is not None:
223+
return lookup
224+
225+
# If we can't find it, then return a function that calculates fresh.
226+
global all_classifiers_map
227+
return all_classifiers_map[key](player)
220228

221229
return classify_player_for_this_classifier
222230

0 commit comments

Comments
 (0)