Skip to content

Commit

Permalink
Merge pull request #5 from timholy/pull-request/fa42eec6
Browse files Browse the repository at this point in the history
Test for nans in cost matrix
  • Loading branch information
PaulBellette authored May 7, 2017
2 parents 802546c + fa42eec commit 8877736
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Munkres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function munkres(cost_matrix)
# and by and Yi Cao's surprisingly fast matlab version,
# http://mathworks.com/matlabcentral/fileexchange/20328-munkres-assignment-algorithm

any(isnan, cost_matrix) && error("cost matrix cannot have NaNs")
n,m = size(cost_matrix)
flipped = false
if n > m
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ tst = [351.0 300.0 662.0 337.0 384.0 935.0 650.0 446.0 57.0 295.0 168.0 398.0 81
p = [9, 6, 18, 3, 4, 17, 16, 7, 13, 20]

@test munkres(tst) == p

@test_throws ErrorException munkres(fill(NaN, (3,3)))

nothing

0 comments on commit 8877736

Please sign in to comment.