Skip to content

Commit 8b1c273

Browse files
committed
Remove distutils usage in plot.py since it's not available in Python 3.12
1 parent 74b0db5 commit 8b1c273

File tree

2 files changed

+1
-38
lines changed

2 files changed

+1
-38
lines changed

axelrod/plot.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pathlib
2-
from distutils.version import LooseVersion
32
from typing import List, Union
43

54
import matplotlib
@@ -16,13 +15,6 @@
1615
dataType = List[List[Union[int, float]]]
1716

1817

19-
def default_cmap(version: str = "2.0") -> str:
20-
"""Sets a default matplotlib colormap based on the version."""
21-
if LooseVersion(version) >= "1.5":
22-
return "viridis"
23-
return "YlGnBu"
24-
25-
2618
class Plot(object):
2719
def __init__(self, result_set: ResultSet) -> None:
2820
self.result_set = result_set
@@ -184,6 +176,7 @@ def _payoff_heatmap(
184176
names: namesType,
185177
title: titleType = None,
186178
ax: matplotlib.axes.SubplotBase = None,
179+
cmap: str = 'viridis'
187180
) -> matplotlib.figure.Figure:
188181
"""Generic heatmap plot"""
189182

@@ -196,8 +189,6 @@ def _payoff_heatmap(
196189
width = max(self.num_players / 4, 12)
197190
height = width
198191
figure.set_size_inches(width, height)
199-
matplotlib_version = matplotlib.__version__
200-
cmap = default_cmap(matplotlib_version)
201192
mat = ax.matshow(data, cmap=cmap)
202193
ax.set_xticks(range(self.result_set.num_players))
203194
ax.set_yticks(range(self.result_set.num_players))

axelrod/tests/unit/test_plot.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,34 +75,6 @@ def setUpClass(cls):
7575
["Defector", "Tit For Tat", "Alternator"],
7676
)
7777

78-
def test_default_cmap(self):
79-
cmap = axl.plot.default_cmap("0.0")
80-
self.assertEqual(cmap, "YlGnBu")
81-
82-
cmap = axl.plot.default_cmap("1.3alpha")
83-
self.assertEqual(cmap, "YlGnBu")
84-
85-
cmap = axl.plot.default_cmap("1.4.99")
86-
self.assertEqual(cmap, "YlGnBu")
87-
88-
cmap = axl.plot.default_cmap("1.4")
89-
self.assertEqual(cmap, "YlGnBu")
90-
91-
cmap = axl.plot.default_cmap()
92-
self.assertEqual(cmap, "viridis")
93-
94-
cmap = axl.plot.default_cmap("1.5")
95-
self.assertEqual(cmap, "viridis")
96-
97-
cmap = axl.plot.default_cmap("1.5beta")
98-
self.assertEqual(cmap, "viridis")
99-
100-
cmap = axl.plot.default_cmap("1.7")
101-
self.assertEqual(cmap, "viridis")
102-
103-
cmap = axl.plot.default_cmap("2.0")
104-
self.assertEqual(cmap, "viridis")
105-
10678
def test_init(self):
10779
plot = axl.Plot(self.test_result_set)
10880
self.assertEqual(plot.result_set, self.test_result_set)

0 commit comments

Comments
 (0)