X-Git-Url: https://git.auder.net/?p=morpheus.git;a=blobdiff_plain;f=pkg%2Ftests%2Ftestthat%2Ftest-hungarianAlgorithm.R;h=3c333b0fbe415d48c73498e2e63a4aef951304a0;hp=591c3c1e673147742b6b0bd8a1c969b464e47d32;hb=2b3a6af5c55ac121405e3a8da721626ddf46b28b;hpb=2989133a738da99b78594cb00afdd3d87916b8bd diff --git a/pkg/tests/testthat/test-hungarianAlgorithm.R b/pkg/tests/testthat/test-hungarianAlgorithm.R index 591c3c1..3c333b0 100644 --- a/pkg/tests/testthat/test-hungarianAlgorithm.R +++ b/pkg/tests/testthat/test-hungarianAlgorithm.R @@ -8,16 +8,17 @@ test_that("HungarianAlgorithm provides the correct answer on various inputs", { # Generate a random vector, and permute it: # we expect the algorithm to retrieve the permutation - v = runif(n, min=-1, max=1) - permutation = sample(1:n) - v_p = v[permutation] + v <- runif(n, min=-1, max=1) + permutation <- sample(1:n) + v_p <- v[permutation] # v is reference, v_p is v after permutation - # distances[i,j] = distance between i-th component of v and j-th component of v_p + # distances[i,j] = distance between i-th component of v + # and j-th component of v_p # "in rows : reference; in columns: after permutation" # "permutation" contains order on v to match v_p as closely as possible - distances = sapply(v_p, function(elt) ( abs(elt - v) ) ) - assignment = .hungarianAlgorithm(distances) + distances <- sapply(v_p, function(elt) ( abs(elt - v) ) ) + assignment <- .hungarianAlgorithm(distances) expect_equal(assignment, permutation) } }