Skip to content

Commit dd63a01

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 8b15237 commit dd63a01

File tree

152 files changed

+1364
-1032
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+1364
-1032
lines changed

benchmarks/benchmarks/compute.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import copy
23
import timeit
34

benchmarks/benchmarks/emd.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12

23
import os
34

@@ -16,10 +17,11 @@
1617
1718
"""
1819

20+
1921
def load_repertoire(name):
2022
"""Load an array of repertoires in ./data/emd/."""
2123
root = os.path.abspath(os.path.dirname(__file__))
22-
filename = os.path.join(root, 'data', 'emd', name)
24+
filename = os.path.join(root, "data", "emd", name)
2325

2426
return np.load(filename)
2527

@@ -31,6 +33,7 @@ def generate_repertoire():
3133

3234
class BenchmarkEmdRandom:
3335
"""Benchmark EMD on random repertoires."""
36+
3437
timeout = 100
3538

3639
def setup(self):
@@ -50,11 +53,12 @@ class BenchmarkEmdRule152:
5053
The data is the first 100,000 repertoires encountered when computing
5154
``big_phi`` for the network.
5255
"""
56+
5357
timeout = 100
5458

5559
def setup(self):
56-
self.d1 = load_repertoire('1.npy')
57-
self.d2 = load_repertoire('2.npy')
60+
self.d1 = load_repertoire("1.npy")
61+
self.d2 = load_repertoire("2.npy")
5862

5963
def time_effect_emd(self):
6064
for d1, d2 in zip(self.d1, self.d2):

benchmarks/benchmarks/subsystem.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import copy
23

34
from pyphi import Subsystem, compute, config, examples
@@ -49,7 +50,7 @@ def clear_network_caches(network):
4950
network.purview_cache = {}
5051

5152

52-
class BenchmarkSubsystem():
53+
class BenchmarkSubsystem:
5354

5455
def setup(self):
5556
# 7-node network
@@ -104,7 +105,7 @@ def time_potential_purviews_with_cache(self):
104105

105106
class BenchmarkEmdApproximation:
106107

107-
params = ['emd', 'l1']
108+
params = ["emd", "l1"]
108109

109110
number = 1
110111
repeat = 1
@@ -116,9 +117,9 @@ def setup(self, distance):
116117

117118
self.default_config = copy.copy(config.__dict__)
118119

119-
if distance == 'emd':
120+
if distance == "emd":
120121
config.L1_DISTANCE_APPROXIMATION = False
121-
elif distance == 'l1':
122+
elif distance == "l1":
122123
config.L1_DISTANCE_APPROXIMATION = True
123124
else:
124125
raise ValueError(distance)

benchmarks/benchmarks/utils.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import numpy as np
23

34
from pyphi import utils
@@ -7,7 +8,8 @@
78
[1, 1, 0, 0, 0],
89
[0, 0, 0, 1, 0],
910
[0, 0, 1, 1, 1],
10-
[1, 0, 0, 1, 1]]
11+
[1, 0, 0, 1, 1],
12+
]
1113

1214
cm1 = [
1315
[0, 1, 1, 0, 1, 0, 0],
@@ -16,7 +18,8 @@
1618
[0, 1, 0, 1, 1, 0, 0],
1719
[0, 0, 0, 1, 1, 0, 0],
1820
[0, 0, 0, 0, 0, 1, 1],
19-
[0, 0, 0, 0, 0, 1, 1]]
21+
[0, 0, 0, 0, 0, 1, 1],
22+
]
2023

2124
cm2 = [
2225
[1, 1, 0, 0, 0, 0, 0, 1],
@@ -26,15 +29,16 @@
2629
[0, 0, 0, 1, 1, 1, 0, 0],
2730
[0, 0, 0, 0, 1, 1, 1, 0],
2831
[0, 0, 0, 0, 0, 1, 1, 1],
29-
[1, 0, 0, 0, 0, 0, 1, 1]]
32+
[1, 0, 0, 0, 0, 0, 1, 1],
33+
]
3034

3135
cm3 = [[1] * 16] * 16
3236

3337

3438
matrices = [cm0, cm1, cm2, cm3]
3539

3640

37-
class BenchmarkBlockCm():
41+
class BenchmarkBlockCm:
3842

3943
params = [0, 1, 2, 3]
4044

@@ -45,19 +49,18 @@ def time_block_cm(self, m):
4549
utils.block_cm(self.cm)
4650

4751

48-
class BenchmarkReducibility():
52+
class BenchmarkReducibility:
4953

50-
params = [[0, 1, 2, 3], ['block', 'full']]
51-
param_names = ['cm', 'type']
54+
params = [[0, 1, 2, 3], ["block", "full"]]
55+
param_names = ["cm", "type"]
5256

5357
def setup(self, m, _type):
5458
self.cm = np.array(matrices[m])
5559

5660
def time_reducibility(self, m, _type):
57-
idxs = (tuple(range(self.cm.shape[0])),
58-
tuple(range(self.cm.shape[1])))
61+
idxs = (tuple(range(self.cm.shape[0])), tuple(range(self.cm.shape[1])))
5962

60-
if _type == 'block':
63+
if _type == "block":
6164
utils.block_reducible(self.cm, *idxs)
62-
elif _type == 'full':
65+
elif _type == "full":
6366
utils.fully_connected(self.cm, *idxs)

0 commit comments

Comments
 (0)