Skip to content

Commit 79a5877

Browse files
committed
[FIX] Fix style
1 parent 7234778 commit 79a5877

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

netneurotools/networks.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ def threshold_network(network, retain=10):
379379

380380

381381
def match_length_degree_distribution(W, D, nbins=10, nswap=1000,
382-
replacement=False, weighted=True,
383-
seed=None):
382+
replacement=False, weighted=True,
383+
seed=None):
384384
"""
385385
Generates degree- and edge length-preserving surrogate connectomes.
386386
@@ -448,7 +448,7 @@ def match_length_degree_distribution(W, D, nbins=10, nswap=1000,
448448
nr = 0
449449
newB = np.copy(B)
450450

451-
while((len(cn_x) >= 2) & (nr < nswap)):
451+
while ((len(cn_x) >= 2) & (nr < nswap)):
452452
# choose randomly the edge to be rewired
453453
r = rs.randint(len(cn_x))
454454
n_x, n_y = cn_x[r], cn_y[r]
@@ -457,7 +457,7 @@ def match_length_degree_distribution(W, D, nbins=10, nswap=1000,
457457
# options to rewire with
458458
# connected nodes that doesn't involve (n_x, n_y)
459459
index = (cn_x != n_x) & (cn_y != n_y) & (cn_y != n_x) & (cn_x != n_y)
460-
if(len(np.where(index)[0]) == 0):
460+
if len(np.where(index)[0]) == 0:
461461
cn_x = np.delete(cn_x, r)
462462
cn_y = np.delete(cn_y, r)
463463

@@ -468,7 +468,7 @@ def match_length_degree_distribution(W, D, nbins=10, nswap=1000,
468468
# L(n_x,n_y) = L(n_x, ops1_x) & L(ops1_x,ops1_y) = L(n_y, ops1_y)
469469
index = (L[n_x, n_y] == L[n_x, ops1_x]) & (
470470
L[ops1_x, ops1_y] == L[n_y, ops1_y])
471-
if(len(np.where(index)[0]) == 0):
471+
if len(np.where(index)[0]) == 0:
472472
cn_x = np.delete(cn_x, r)
473473
cn_y = np.delete(cn_y, r)
474474

@@ -479,7 +479,7 @@ def match_length_degree_distribution(W, D, nbins=10, nswap=1000,
479479
& (newB[min(n_y, ops2_y[i])][max(n_y,
480480
ops2_y[i])] == 0)
481481
for i in range(len(ops2_x))]
482-
if(len(np.where(index)[0]) == 0):
482+
if (len(np.where(index)[0]) == 0):
483483
cn_x = np.delete(cn_x, r)
484484
cn_y = np.delete(cn_y, r)
485485

@@ -513,27 +513,27 @@ def match_length_degree_distribution(W, D, nbins=10, nswap=1000,
513513
cn_x = np.delete(cn_x, index)
514514
cn_y = np.delete(cn_y, index)
515515

516-
if(nr < nswap):
516+
if nr < nswap:
517517
print(f"I didn't finish, out of rewirable edges: {len(cn_x)}")
518518

519519
i, j = np.triu_indices(N, k=1)
520520
# Make the connectivity matrix symmetric
521521
newB[j, i] = newB[i, j]
522522

523523
# check the number of edges is preserved
524-
if(len(np.where(B != 0)[0]) != len(np.where(newB != 0)[0])):
524+
if len(np.where(B != 0)[0]) != len(np.where(newB != 0)[0]):
525525
print(
526526
f"ERROR --- number of edges changed, \
527527
B:{len(np.where(B!=0)[0])}, newB:{len(np.where(newB!=0)[0])}")
528528
# check that the degree of the nodes it's the same
529529
for i in range(N):
530-
if(np.sum(B[i]) != np.sum(newB[i])):
530+
if np.sum(B[i]) != np.sum(newB[i]):
531531
print(
532532
f"ERROR --- node {i} changed k by: \
533533
{np.sum(B[i]) - np.sum(newB[i])}")
534534

535535
newW = np.zeros((N, N))
536-
if(weighted):
536+
if weighted:
537537
# Reassign the weights
538538
mask = np.triu(B != 0, k=1)
539539
inids = D[mask]

0 commit comments

Comments
 (0)