test_that("canonical distance function names are available", { expected = c( "Gini_Distance", "EndresSchindelin_Distance", "Fractional_Distance", "MSMD_Distance", "Minkowski_Distance", "SharedNeighbor_Distance", "DTW_Distance", "Tfidf_Distance", "TWED_Distance", "Wasserstein_Distance", "Jaccard_Distance" ) for (name in expected) { expect_true( exists(name, envir = asNamespace("BIDistances"), mode = "function"), info = name ) } }) test_that("Tfidf_dist remains the only legacy function alias", { Gene2GO = rbind( Gene1 = c(1, 0, 2), Gene2 = c(0, 1, 1), Gene3 = c(1, 1, 0) ) expect_equal(Tfidf_Distance(Gene2GO), Tfidf_dist(Gene2GO)) }) test_that("Cosine_Distance returns distance rather than similarity", { Data = rbind( SameDirection1 = c(1, 0), Orthogonal = c(0, 1), SameDirection2 = c(2, 0), Zero1 = c(0, 0), Zero2 = c(0, 0) ) Distance = Cosine_Distance(Data) expect_equal(Distance[1, 3], 0) expect_equal(Distance[1, 2], 1) expect_equal(Distance[4, 5], 0) expect_equal( diag(Distance), setNames(rep(0, nrow(Data)), rownames(Data)) ) expect_equal(Distance, t(Distance)) })