R Under development (unstable) (2024-09-28 r87201 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(testthat) > # library(orthoclust) > > # test_check("orthoclust") > > set.seed(12345) > n1 <- 20 > n2 <- 20 > n <- n1 + n2 > p.within <- .5 > p.between <- .1 > P <- matrix(p.between, nrow = n, ncol = n) > P[seq(n1), seq(n1)] <- p.within > P[seq(n1 + 1, n), seq(n1 + 1, n)] <- p.within > A <- orthoclust::draw.graph(P) > > testthat::test_that('draw.graph outputs an adjacency matrix', { + testthat::expect_equal(nrow(A), n) + testthat::expect_equal(ncol(A), n) + testthat::expect_equal(A, t(A)) + testthat::expect_equal(sum(abs(diag(A))), 0) + testthat::expect_true(all(A >= 0)) + }) Test passed 😸 > > K <- 2 > out.sbm <- orthoclust::osc(A, K = K, model = 'sbm') > out.pabm <- orthoclust::osc(A, K = K, model = 'pabm') > > testthat::test_that('check for outputs of osc', { + testthat::expect_true(all(out.sbm$clustering %in% seq(K))) + testthat::expect_equal(nrow(out.sbm$embedding), n) + testthat::expect_equal(ncol(out.sbm$embedding), K) + testthat::expect_true(all(out.pabm$clustering %in% seq(K))) + testthat::expect_equal(nrow(out.pabm$embedding), n) + testthat::expect_equal(ncol(out.pabm$embedding), K ^ 2) + }) Test passed 🥳 > > proc.time() user system elapsed 1.12 0.18 1.28