File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ def test_make_cost_thresh_lookup():
50
50
# costs in ascending order
51
51
## last vector is same as second vector rounded to 2 decimals
52
52
npt .assert_almost_equal (lookup .actual_cost , lookup .cost , decimal = 2 )
53
+ # add nan to adj_mat to raise error
54
+ adj_mat [2 ,:] = np .nan
55
+ npt .assert_raises (ValueError , util .make_cost_thresh_lookup , adj_mat )
56
+
53
57
54
58
def test_cost_size ():
55
59
n_nodes = 5
Original file line number Diff line number Diff line change @@ -192,7 +192,11 @@ def make_cost_thresh_lookup(adjacency_matrix):
192
192
0.70
193
193
194
194
"""
195
-
195
+ ## check for nan in matrix, sorting will behave badly if nan found
196
+ if np .any (np .isnan (adjacency_matrix )):
197
+ raise ValueError ('NAN found in adjacency matrix, this will cause' \
198
+ 'improper behavior in sorting and improper results, ' \
199
+ 'please remove all nan ' )
196
200
ind = np .triu_indices_from (adjacency_matrix , k = 1 )
197
201
edges = adjacency_matrix [ind ]
198
202
nedges = edges .shape [0 ]
You can’t perform that action at this time.
0 commit comments