Skip to content

Commit 9590f0b

Browse files
committed
Fix flake8
1 parent 26e8e70 commit 9590f0b

4 files changed

Lines changed: 38 additions & 36 deletions

File tree

docs/source/diffusion.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ References
9595
.. [3] Mostafavi, S., *et al.* (2008). Genemania: a real-time multiple association network integration algorithm for
9696
predicting gene function.Genome Biology. (9), S4.
9797
98-
.. [4] Harchaoui, Z., *et al.* (2013). Kernel-based methods for hypothesis testing: a unified view. IEEE Signal Processing
99-
Magazine. (30), 87–97.
98+
.. [4] Harchaoui, Z., *et al.* (2013). Kernel-based methods for hypothesis testing: a unified view. IEEE Signal
99+
Processing Magazine. (30), 87–97.
100100
101101
.. [5] Bersanelli, M. *et al.* (2016). Network diffusion-based analysis of high-throughput data for the detection of
102102
differentially enriched modules. Scientific Reports. (6), 34841.
103103
104-
.. [6] Tsuda, K., *et al.* (2005). Fast protein classification with multiple networks. Bioinformatics, (21), 59–65.
104+
.. [6] Tsuda, K., *et al.* (2005). Fast protein classification with multiple networks. Bioinformatics, (21), 59–65
105105
106106

src/diffupy/diffuse_raw.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020

2121

2222
def calculate_scores(
23-
col_ind: int,
24-
scores: np.array,
25-
diff: np.array,
26-
const_mean: np.array,
27-
const_var: np.array
23+
col_ind: int,
24+
scores: np.array,
25+
diff: np.array,
26+
const_mean: np.array,
27+
const_var: np.array
2828
) -> float:
2929
"""Help function for diffuse_raw, which operate the z-scores calculation given a whole column of the score matrix.
3030
@@ -51,10 +51,10 @@ def calculate_scores(
5151

5252

5353
def diffuse_raw(
54-
graph: nx.Graph,
55-
scores: Matrix,
56-
z: bool = False,
57-
k: Matrix = None,
54+
graph: nx.Graph,
55+
scores: Matrix,
56+
z: bool = False,
57+
k: Matrix = None,
5858
) -> Matrix:
5959
"""Compute the score diffusion procedure, given an initial state as a set of scores and a network where diffuse it.
6060
@@ -103,9 +103,9 @@ def diffuse_raw(
103103
if not z:
104104
return Matrix(
105105
diff,
106-
rows_labels = scores.rows_labels,
107-
cols_labels = ['output diffusion scores'],
108-
name = scores.name
106+
rows_labels=scores.rows_labels,
107+
cols_labels=['output diffusion scores'],
108+
name=scores.name
109109
)
110110

111111
logging.info('Normalization z-scores.')
@@ -140,7 +140,7 @@ def diffuse_raw(
140140
)
141141
for i in range(diff.shape[1])
142142
]),
143-
rows_labels = scores.rows_labels,
144-
cols_labels = ['output diffusion scores'],
145-
name = scores.name
143+
rows_labels=scores.rows_labels,
144+
cols_labels=['output diffusion scores'],
145+
name=scores.name
146146
)

src/diffupy/matrix.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ class Matrix:
2323
"""Matrix class."""
2424

2525
def __init__(
26-
self,
27-
mat=None,
28-
rows_labels=None,
29-
cols_labels=None,
30-
graph=None,
31-
quadratic=False,
32-
name='',
33-
init_value=None,
34-
**kwargs
26+
self,
27+
mat=None,
28+
rows_labels=None,
29+
cols_labels=None,
30+
graph=None,
31+
quadratic=False,
32+
name='',
33+
init_value=None,
34+
**kwargs
3535
):
3636
"""Initialize matrix.
3737
@@ -87,7 +87,7 @@ def __str__(self):
8787
return f"\nmatrix {self.name} \n {s} \n "
8888

8989
def __iter__(self, **kargs):
90-
"""Helper method for the iteration of the Matrix."""
90+
"""Help method for the iteration of the Matrix."""
9191
self.i = -1
9292
self.j = 0
9393

@@ -99,7 +99,7 @@ def __iter__(self, **kargs):
9999
return self
100100

101101
def __next__(self):
102-
"""Helper method for the iteration of the Matrix."""
102+
"""Help method for the iteration of the Matrix."""
103103
if self.i >= len(self.rows_labels) - 1 and self.j >= len(self.cols_labels) - 1:
104104
self.get_labels = True
105105
self.get_indices = False
@@ -381,7 +381,7 @@ def match_mat(self, reference_matrix, match_quadratic=None):
381381

382382
return mat_match
383383

384-
def match_missing_rows(self, reference_labels, missing_fill = 0):
384+
def match_missing_rows(self, reference_labels, missing_fill=0):
385385
"""Match method to set missing rows labels from reference labels with the missing_fill value."""
386386
if reference_labels == self.rows_labels:
387387
return self
@@ -482,7 +482,7 @@ def from_csv(self, csv_path):
482482

483483
"""Export"""
484484

485-
def to_dict(self, ordered = True):
485+
def to_dict(self, ordered=True):
486486
"""Export/convert matrix as a dictionary data structure."""
487487
if ordered:
488488
mat = self.order_rows()
@@ -496,15 +496,17 @@ def to_dict(self, ordered = True):
496496

497497
return d
498498

499-
def to_csv(self, path, file_name = '_export.csv', index = False, ordered = True):
499+
def to_csv(self, path, file_name='_export.csv', index=False, ordered=True):
500500
"""Export matrix to csv file using the headers (row_labels, cols_labels) of the Matrix class."""
501501
# Generate dataframe
502-
df = pd.DataFrame(data = self.to_dict(ordered))
502+
df = pd.DataFrame(data=self.to_dict(ordered))
503+
504+
df.to_csv(os.path.join(path, self.name, file_name), index=index)
503505

504-
df.to_csv(os.path.join(path, self.name, file_name), index = index)
505506

506507
class LaplacianMatrix(Matrix):
507508
"""Laplacian matrix class."""
509+
508510
def __init__(self, graph, normalized=False, name=''):
509511
"""Initialize laplacian."""
510512
l_mat = get_laplacian(graph, normalized)

tests/test_input.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from diffupy.process_input import process_input, map_nodes
1111
from diffupy.utils import process_network
1212
from diffupy.validate_input import _validate_scores
13+
1314
from tests.constants import *
1415

1516
log = logging.getLogger(__name__)
@@ -135,8 +136,7 @@ def test_network(self):
135136
})
136137

137138
def test_node_mapping(self):
138-
"""Test mapping of nodes in label_input to nodes in network"""
139-
139+
"""Test mapping of nodes in label_input to nodes in network."""
140140
input = NODE_LOGFC_TEST_PATH
141141
input_labels_dict = process_input(
142142
input, method=RAW, binning=False, absolute_value=True, p_value=0.05, threshold=0.5,

0 commit comments

Comments
 (0)