Skip to content

Commit f8469d9

Browse files
committed
Add documentation to cost_size and cleanup style.
1 parent c8f67e5 commit f8469d9

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

brainx/util.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,31 @@ def format_matrix2(data,s,sc,c,lk,co,idc = [],costlist=[],nouptri = False):
6060

6161

6262
def cost_size(nnodes):
63-
tot_edges = .5*nnodes*(nnodes-1)
64-
costs = np.array(range(int(tot_edges)+1),dtype=float)/tot_edges
65-
edges_short = tot_edges/2
66-
return costs,tot_edges,edges_short
63+
"""Make N-length array of costs, with N the number of possible edges.
64+
65+
Parameters
66+
----------
67+
nnodes: integer
68+
Number of nodes in the graph.
69+
70+
Returns
71+
-------
72+
costs: numpy array
73+
N-length array of costs, with N the number of possible
74+
undirected edges in the graph. The costs range from 0 to 1 and
75+
are equally-spaced.
76+
77+
tot_edges: float
78+
Number of possible undirected edges in the graph.
79+
80+
half_tot_edges: float
81+
tot_edges / 2
82+
83+
"""
84+
tot_edges = 0.5 * nnodes * (nnodes - 1)
85+
costs = np.array(range(int(tot_edges) + 1), dtype=float) / tot_edges
86+
half_tot_edges = tot_edges / 2
87+
return costs, tot_edges, half_tot_edges
6788

6889

6990
def store_metrics(b, s, co, metd, arr):

0 commit comments

Comments
 (0)