diff --git a/tests/testthat/test-MADMMplasso.R b/tests/testthat/test-MADMMplasso.R index 92e471f..b555d98 100644 --- a/tests/testthat/test-MADMMplasso.R +++ b/tests/testthat/test-MADMMplasso.R @@ -103,7 +103,7 @@ fit_R <- suppressWarnings( test_that("C++ and R versions basically output the same thing", { expect_named(fit_C$beta, names(fit_R$beta)) tl <- 1e1 - expect_equal(fit_C$beta0[, , 1], fit_R$beta0[[1]][1, ], tolerance = tl) + expect_equal(fit_C$beta0[, , 1], fit_R$beta0[[1]], tolerance = tl) expect_equal(as.vector(fit_C$beta[, , 1]), as.vector(fit_R$beta[[1]]), tolerance = tl) expect_equal(as.vector(fit_C$BETA_hat[, , 1]), as.vector(fit_R$BETA_hat[[1]]), tolerance = tl) expect_equal(fit_C$theta0[, , 1], fit_R$theta0[[1]], tolerance = tl) diff --git a/tests/testthat/test-admm_MADMMplasso_cpp.R b/tests/testthat/test-admm_MADMMplasso_cpp.R index a2a965b..20b22d1 100644 --- a/tests/testthat/test-admm_MADMMplasso_cpp.R +++ b/tests/testthat/test-admm_MADMMplasso_cpp.R @@ -171,7 +171,7 @@ beta_hat <- my_values$beta_hat y_hat <- my_values$y_hat test_that("final objects have correct dimensions", { - expect_identical(dim(beta0), c(1L, 6L)) + expect_identical(length(beta0), 6L) expect_identical(dim(theta0), c(4L, 6L)) expect_identical(dim(beta), c(50L, 6L)) expect_identical(dim(theta), c(50L, 4L, 6L)) @@ -205,7 +205,7 @@ test_that("C++ function output structure", { test_that("Values are the same", { tl <- 1e-1 - expect_equal(my_values$beta0, t(my_values_cpp$beta0), tolerance = tl) + expect_equal(my_values$beta0, my_values_cpp$beta0[, 1], tolerance = tl) expect_equal(my_values$theta0, my_values_cpp$theta0, tolerance = tl) expect_equal(my_values$beta, my_values_cpp$beta, tolerance = tl) expect_equal(my_values$theta, my_values_cpp$theta, tolerance = tl) diff --git a/tests/testthat/test-reg.R b/tests/testthat/test-reg.R index 0d78536..8a47ee5 100644 --- a/tests/testthat/test-reg.R +++ b/tests/testthat/test-reg.R @@ -18,6 +18,7 @@ test_that("reg() produces the correct output", { for (rp in seq_len(reps)) { r <- matrix(rnorm(n_obs[rp] * n_vars[rp]), n_obs[rp], n_vars[rp]) z <- as.matrix(sample(0:1, n_obs[rp], replace = TRUE)) - expect_identical(reg(r, z), reg_R(r, z), tolerance = 1e-10) + expect_identical(reg(r, z)[1, ], reg_R(r, z)[[1]][1, ], tolerance = 1e-10) + expect_identical(reg(r, z)[2, ], reg_R(r, z)[[2]][1, ], tolerance = 1e-10) } })