Skip to content

Commit 98aea63

Browse files
committed
Resurrect cost_size (w/ DeprecationWarning), write test for it.
1 parent df38b76 commit 98aea63

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

brainx/tests/test_util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
#-----------------------------------------------------------------------------
1717
# Functions
1818
#-----------------------------------------------------------------------------
19+
20+
def test_cost_size():
21+
n_nodes = 5
22+
npt.assert_warns(DeprecationWarning, util.cost_size, n_nodes)
23+
24+
1925
def test_apply_cost():
2026
corr_mat = np.array([[0.0, 0.5, 0.3, 0.2, 0.1],
2127
[0.5, 0.0, 0.4, 0.1, 0.2],

brainx/util.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#-----------------------------------------------------------------------------
77
from __future__ import print_function
88

9-
import numpy as np
9+
import warnings
1010

11+
import numpy as np
1112
import networkx as nx
1213

1314
#-----------------------------------------------------------------------------
@@ -60,6 +61,14 @@ def format_matrix2(data,s,sc,c,lk,co,idc = [],costlist=[],nouptri = False):
6061
return cmat
6162

6263

64+
def cost_size(nnodes):
65+
warnings.warn('deprecated: use make_cost_array', DeprecationWarning)
66+
tot_edges = 0.5 * nnodes * (nnodes - 1)
67+
costs = np.array(range(int(tot_edges) + 1), dtype=float) / tot_edges
68+
edges_short = tot_edges / 2
69+
return costs, tot_edges, edges_short
70+
71+
6372
def make_cost_array(n_nodes, cost=0.5):
6473
"""Make cost array of length cost * (the number of possible edges).
6574

0 commit comments

Comments
 (0)