Skip to content

Commit e82a32f

Browse files
committed
Adhere to pep8
1 parent f03509b commit e82a32f

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

simulation/minimal_distances.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def single_source_dijkstra_hyperedges(hypergraph: TimeVaryingHypergraph, source_
3737
case DistanceType.SHORTEST:
3838
new_distance = prior_distance + 1
3939
case DistanceType.FASTEST:
40-
new_distance = prior_distance + (next_hedge_timing - source_hedge_timing)
40+
new_distance = prior_distance + \
41+
(next_hedge_timing - source_hedge_timing)
4142
case DistanceType.FOREMOST:
4243
new_distance = next_hedge_timing
4344
if next_hedge not in hedge_distances or new_distance < hedge_distances[next_hedge]:
@@ -86,7 +87,8 @@ def single_source_dijkstra_vertices(hypergraph: TimeVaryingHypergraph, source_ve
8687
case DistanceType.SHORTEST:
8788
new_distance = distance + 1
8889
case DistanceType.FASTEST:
89-
new_distance = distance + (next_hedge_timing - source_hedge_timing)
90+
new_distance = distance + \
91+
(next_hedge_timing - source_hedge_timing)
9092
case DistanceType.FOREMOST:
9193
new_distance = next_hedge_timing
9294
if new_reachable not in distances or new_distance < distances[new_reachable]:

test/test_minimal_distances.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,21 @@ def test_minimal_distance(self):
6161
for start_vertex, _minimal_distances in minimal_distances.items():
6262
for distance_type in DistanceType:
6363
with self.subTest(implementation='single_source_dijkstra_vertices', distance_type=distance_type.name, communication_network=communication_network.name):
64-
self.assertEqual(single_source_dijkstra_vertices(communication_network, start_vertex, distance_type, min_timing=0), _minimal_distances[distance_type])
64+
self.assertEqual(single_source_dijkstra_vertices(
65+
communication_network, start_vertex, distance_type, min_timing=0), _minimal_distances[distance_type])
6566

6667
with self.subTest(implementation='single_source_dijkstra_hyperedges', distance_type=distance_type.name, communication_network=communication_network.name):
67-
self.assertEqual(single_source_dijkstra_hyperedges(communication_network, start_vertex, distance_type, min_timing=0), _minimal_distances[distance_type])
68+
self.assertEqual(single_source_dijkstra_hyperedges(
69+
communication_network, start_vertex, distance_type, min_timing=0), _minimal_distances[distance_type])
6870

6971
def test_pairwise_minimal_distance(self):
7072
for communication_network in (MinimalPathTest.communication_network_1, MinimalPathTest.communication_network_2, ):
7173
for distance_type in DistanceType:
7274
for vertex in communication_network.vertices():
7375
with self.subTest(distance_type=distance_type.name, vertex=vertex):
74-
result_1 = single_source_dijkstra_vertices(communication_network, vertex, distance_type, min_timing=0)
75-
result_2 = single_source_dijkstra_hyperedges(communication_network, vertex, distance_type, min_timing=0)
76-
self.assertEqual(result_1, result_2, f'Single-source Dijkstra implementations for {distance_type.name} and vertex {vertex} are not equivalent')
76+
result_1 = single_source_dijkstra_vertices(
77+
communication_network, vertex, distance_type, min_timing=0)
78+
result_2 = single_source_dijkstra_hyperedges(
79+
communication_network, vertex, distance_type, min_timing=0)
80+
self.assertEqual(result_1, result_2, f'Single-source Dijkstra implementations for {
81+
distance_type.name} and vertex {vertex} are not equivalent')

test/test_model.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,24 @@ class TimeVaryingHypergraphTest(unittest.TestCase):
1111
def test_vertices(self):
1212
for hedge, vertices in TimeVaryingHypergraphTest.hyperedges.items():
1313
with self.subTest(hyperedge=hedge):
14-
self.assertEqual(TimeVaryingHypergraphTest.hypergraph.vertices(hedge), set(vertices))
14+
self.assertEqual(
15+
TimeVaryingHypergraphTest.hypergraph.vertices(hedge), set(vertices))
1516

1617
def test_hyperedges(self):
17-
self.assertEqual(TimeVaryingHypergraphTest.hypergraph.hyperedges('v1'), {'h1'})
18+
self.assertEqual(
19+
TimeVaryingHypergraphTest.hypergraph.hyperedges('v1'), {'h1'})
1820

1921
def test_timings(self):
20-
self.assertEqual(TimeVaryingHypergraphTest.hypergraph.timings(), TimeVaryingHypergraphTest.timings)
22+
self.assertEqual(TimeVaryingHypergraphTest.hypergraph.timings(
23+
), TimeVaryingHypergraphTest.timings)
2124

2225
def test_unknown_vertex(self):
23-
self.assertRaises(EntityNotFound, TimeVaryingHypergraphTest.hypergraph.vertices, 'vx')
26+
self.assertRaises(
27+
EntityNotFound, TimeVaryingHypergraphTest.hypergraph.vertices, 'vx')
2428

2529
def test_unknown_hyperedge(self):
26-
self.assertRaises(EntityNotFound, TimeVaryingHypergraphTest.hypergraph.hyperedges, 'hx')
30+
self.assertRaises(
31+
EntityNotFound, TimeVaryingHypergraphTest.hypergraph.hyperedges, 'hx')
2732

2833

2934
class CommunicationNetworkTest(unittest.TestCase):
@@ -34,23 +39,28 @@ class CommunicationNetworkTest(unittest.TestCase):
3439
def test_pairwise_vertex_participant_equivalence(self):
3540
for hedge in list(CommunicationNetworkTest.hyperedges):
3641
with self.subTest(hyperedge=hedge):
37-
self.assertEqual(CommunicationNetworkTest.communication_network.vertices(hedge), CommunicationNetworkTest.communication_network.participants(hedge))
42+
self.assertEqual(CommunicationNetworkTest.communication_network.vertices(
43+
hedge), CommunicationNetworkTest.communication_network.participants(hedge))
3844

3945
def test_vertex_participant_equivalence(self):
40-
self.assertEqual(CommunicationNetworkTest.communication_network.vertices(), CommunicationNetworkTest.communication_network.participants())
46+
self.assertEqual(CommunicationNetworkTest.communication_network.vertices(
47+
), CommunicationNetworkTest.communication_network.participants())
4148

4249
def test_pairwise_hyperedge_channel_equivalence(self):
4350
for vertex in {v for vertices in CommunicationNetworkTest.hyperedges.values() for v in vertices}:
4451
with self.subTest(hyperedge=vertex):
45-
self.assertEqual(CommunicationNetworkTest.communication_network.hyperedges(vertex), CommunicationNetworkTest.communication_network.channels(vertex))
52+
self.assertEqual(CommunicationNetworkTest.communication_network.hyperedges(
53+
vertex), CommunicationNetworkTest.communication_network.channels(vertex))
4654

4755
def test_hyperedge_channel_equivalence(self):
48-
self.assertEqual(CommunicationNetworkTest.communication_network.hyperedges(), CommunicationNetworkTest.communication_network.channels())
56+
self.assertEqual(CommunicationNetworkTest.communication_network.hyperedges(
57+
), CommunicationNetworkTest.communication_network.channels())
4958

5059

5160
class ParametrizedCommunicationNetworkTest(unittest.TestCase):
5261
def test_with_paramtrization(self):
53-
communciation_network = CommunicationNetwork.from_json('./data/networks/microsoft.json.bz2')
62+
communciation_network = CommunicationNetwork.from_json(
63+
'./data/networks/microsoft.json.bz2')
5464
with self.subTest():
5565
self.assertEqual(len(communciation_network.participants()), 37103)
5666
with self.subTest():

test/test_results.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ class ResultsTest(unittest.TestCase):
2424
@unittest.skipIf(not ZENODO_ACCESS_TOKEN or not REQUESTS_INSTALLED, 'Skipped because no Zenodo access token was provided.')
2525
def test_results(self):
2626
zenodo_access_token = os.environ.get('ZENODO_ACCESS_TOKEN')
27-
response = requests.get('https://zenodo.org/api/records/8042256', params={'access_token': zenodo_access_token}, timeout=10)
27+
response = requests.get('https://zenodo.org/api/records/8042256',
28+
params={'access_token': zenodo_access_token}, timeout=10)
2829
response.raise_for_status()
29-
zenodo_reference = {record['key']: record['checksum'][len('md5:'):] for record in response.json()['files']}
30+
zenodo_reference = {record['key']: record['checksum'][len(
31+
'md5:'):] for record in response.json()['files']}
3032
if zenodo_reference:
3133
for file_path in sorted(Path('./').glob('./data/minimal_distances/*.bz2'), reverse=True):
3234
file_name = file_path.name
3335
with self.subTest(file_name=file_name):
3436
md5_hash = md5(file_path)
3537
md5_hash_reference = zenodo_reference.get(file_name)
36-
self.assertEqual(md5_hash, md5_hash_reference, 'md5 hash is not equivalent with reference on Zenodo')
38+
self.assertEqual(
39+
md5_hash, md5_hash_reference, 'md5 hash is not equivalent with reference on Zenodo')

0 commit comments

Comments
 (0)