Skip to content

Commit 9003610

Browse files
committed
Add test for re-shaping data
1 parent addebb5 commit 9003610

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

axelrod/tests/unit/test_fingerprint.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,33 @@ def test_generate_data(self):
160160
self.assertEqual(sorted(keys), self.expected_points)
161161
self.assertEqual(all(values), True)
162162

163+
def test_reshape_data(self):
164+
test_points = [Point(x=0.0, y=0.0),
165+
Point(x=0.0, y=0.5),
166+
Point(x=0.0, y=1.0),
167+
Point(x=0.5, y=0.0),
168+
Point(x=0.5, y=0.5),
169+
Point(x=0.5, y=1.0),
170+
Point(x=1.0, y=0.0),
171+
Point(x=1.0, y=0.5),
172+
Point(x=1.0, y=1.0)]
173+
test_data = {Point(x=0.0, y=0.0): 5,
174+
Point(x=0.0, y=0.5): 9,
175+
Point(x=0.0, y=1.0): 3,
176+
Point(x=0.5, y=0.0): 8,
177+
Point(x=0.5, y=0.5): 2,
178+
Point(x=0.5, y=1.0): 4,
179+
Point(x=1.0, y=0.0): 2,
180+
Point(x=1.0, y=0.5): 1,
181+
Point(x=1.0, y=1.0): 9}
182+
test_shaped_data = [[3, 4, 9],
183+
[9, 2, 1],
184+
[5, 8, 2]]
185+
af = AshlockFingerprint(self.strategy, self.probe)
186+
plotting_data = af.reshape_data(test_data, test_points, 3)
187+
for i in range(len(plotting_data)):
188+
self.assertEqual(list(plotting_data[i]), test_shaped_data[i])
189+
163190
def test_plot(self):
164191
af = AshlockFingerprint(self.strategy, self.probe)
165192
af.fingerprint(turns=10, repetitions=2, step=0.25, progress_bar=False)

0 commit comments

Comments
 (0)