Skip to content

Commit 402b3e9

Browse files
committed
fixed pep8ing
1 parent 68c55d8 commit 402b3e9

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

ndmg/stats/graph_qc.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -57,50 +57,50 @@ def compute_metrics(fs, outdir, atlas, verb=False):
5757
# Number of non-zero edges (i.e. binary edge count)
5858
print("Computing: NNZ")
5959
nnz = OrderedDict((subj, len(nx.edges(graphs[subj]))) for subj in graphs)
60-
write(outdir, 'number_non_zeros', nnz, atlas)
60+
write(outdir, 'number_non_zeros', nnz, atlas)
6161

6262
# Degree sequence
6363
print("Computing: Degree Seuqence")
6464
temp_deg = OrderedDict((subj, np.array(nx.degree(graphs[subj]).values()))
65-
for subj in graphs)
65+
for subj in graphs)
6666
deg = density(temp_deg)
67-
write(outdir, 'degree_distribution', deg, atlas)
67+
write(outdir, 'degree_distribution', deg, atlas)
6868

6969
# Edge Weights
7070
print("Computing: Edge Weight Sequence")
71-
temp_ew = OrderedDict((subj, [graphs[subj].get_edge_data(e[0], e[1])['weight']
72-
for e in graphs[subj].edges()]) for subj in graphs)
71+
temp_ew = OrderedDict((s, [graphs[s].get_edge_data(e[0], e[1])['weight']
72+
for e in graphs[s].edges()]) for s in graphs)
7373
ew = density(temp_ew)
74-
write(outdir, 'edge_weight_distribution', ew, atlas)
74+
write(outdir, 'edge_weight_distribution', ew, atlas)
7575

7676
# Clustering Coefficients
7777
print("Computing: Clustering Coefficient Sequence")
7878
temp_cc = OrderedDict((subj, nx.clustering(graphs[subj]).values())
79-
for subj in graphs)
79+
for subj in graphs)
8080
ccoefs = density(temp_cc)
81-
write(outdir, 'clustering_coefficients', ccoefs, atlas)
81+
write(outdir, 'clustering_coefficients', ccoefs, atlas)
8282

8383
# Scan Statistic-1
8484
print("Computing: Scan Statistic-1 Sequence")
8585
temp_ss1 = scan_statistic(graphs, 1)
8686
ss1 = density(temp_ss1)
87-
write(outdir, 'scan_statistic_1', ss1, atlas)
87+
write(outdir, 'scan_statistic_1', ss1, atlas)
8888

8989
# Eigen Values
9090
print("Computing: Eigen Value Sequence")
9191
laplac = OrderedDict((subj, nx.normalized_laplacian_matrix(graphs[subj]))
92-
for subj in graphs)
92+
for subj in graphs)
9393
eigs = OrderedDict((subj, np.sort(np.linalg.eigvals(laplac[subj].A))[::-1])
94-
for subj in graphs)
95-
write(outdir, 'eigen_sequence', eigs, atlas)
94+
for subj in graphs)
95+
write(outdir, 'eigen_sequence', eigs, atlas)
9696

9797
# Betweenness Centrality
9898
print("Computing: Betweenness Centrality Sequence")
9999
nxbc = nx.algorithms.betweenness_centrality # For PEP8 line length...
100100
temp_bc = OrderedDict((subj, nxbc(graphs[subj]).values())
101-
for subj in graphs)
101+
for subj in graphs)
102102
centrality = density(temp_bc)
103-
write(outdir, 'betweenness_centrality', centrality, atlas)
103+
write(outdir, 'betweenness_centrality', centrality, atlas)
104104

105105
outf = outdir + '/' + atlas + '_summary.png'
106106

ndmg/stats/plot_metrics.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,23 @@
1919
# Created by Greg Kiar on 2016-05-11.
2020
# Email: gkiar@jhu.edu
2121

22-
import numpy as np
23-
import networkx as nx
24-
import matplotlib
25-
matplotlib.use('Agg') #very important this is above pyplot import
26-
27-
import matplotlib.pyplot as plt
28-
import matplotlib.ticker as mtick
2922
import time
3023
import json
3124
import sys
3225
import os
26+
import numpy as np
27+
import networkx as nx
28+
import matplotlib; matplotlib.use('Agg') # very important above pyplot import
29+
import matplotlib.pyplot as plt
30+
import matplotlib.ticker as mtick
3331

34-
font = {'weight' : 'bold',
35-
'size' : 14}
32+
font = {'weight': 'bold',
33+
'size': 14}
3634
matplotlib.rc('font', **font)
3735

3836
cols = '#000000'
3937

38+
4039
class plot_metrics():
4140

4241
def __init__(self, nnz, deg, ew, ccoefs, ss1, eigs, centrality, outf):
@@ -93,7 +92,7 @@ def plotting(self):
9392
plt.savefig(self.outf, bbox_inches='tight')
9493
# plt.show()
9594

96-
metadata = {"subjects" : self.nnz.keys(),
95+
metadata = {"subjects": self.nnz.keys(),
9796
"date": time.asctime(time.localtime())}
9897
with open(os.path.splitext(self.outf)[0]+'_info.json', 'w') as fp:
9998
json.dump(metadata, fp)
@@ -135,8 +134,8 @@ def plot_helper(self, data, tit, typ='hi'):
135134
def rand_jitter(self, arr):
136135
stdev = .03*(max(arr)-min(arr)+2)
137136
return arr + np.random.randn(len(arr)) * stdev
138-
139-
def factors(self, N):
137+
138+
def factors(self, N):
140139
factors = [subitem for subitem in [(i, N//i)
141140
for i in range(1, int(N**0.5) + 1)
142141
if N % i == 0 and i > 1]]

ndmg/utils/bids_s3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_data(bucket, remote_path, local, subj=None):
3434
if bucket not in bkts:
3535
sys.exit("Error: could not locate bucket. Available buckets: " +
3636
", ".join(bkts))
37-
37+
3838
cmd = "".join(['aws s3 cp --recursive s3://', bucket, '/',
3939
remote_path])
4040
if subj is not None:

ndmg/utils/loadGraphs.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import sys
2727
import os
2828

29+
2930
def loadGraphs(filenames, verb=False):
3031
"""
3132
Given a list of files, returns a dictionary of graphs
@@ -38,7 +39,8 @@ def loadGraphs(filenames, verb=False):
3839
- Toggles verbose output statements
3940
"""
4041
# Initializes empty dictionary
41-
if type(filenames) is not list: filenames = [filenames]
42+
if type(filenames) is not list:
43+
filenames = [filenames]
4244
gstruct = OrderedDict()
4345
for idx, files in enumerate(filenames):
4446
if verb:

0 commit comments

Comments
 (0)