Skip to content

Commit

Permalink
Adapted tests to new C++ output format (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Jun 25, 2024
1 parent 1c72dcb commit d72c8df
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/testthat/test-MADMMplasso.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,21 @@ 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]], 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)
expect_equal(fit_C$beta0[[1]], as.matrix(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)
for (i in 1:6) {
expect_equal(as.vector(fit_C$theta[[1]][, , i]), as.vector(fit_R$theta[[1]][, , i]), tolerance = tl)
expect_equal(
as.vector(fit_C$theta[[1]][, , i]),
as.vector(fit_R$theta[[1]][, , i]),
tolerance = tl
)
}
expect_equal(fit_C$path, fit_R$path, tolerance = tl)
expect_identical(fit_C$Lambdas, fit_R$Lambdas)
expect_identical(fit_C$non_zero[1], fit_R$non_zero)
expect_identical(fit_C$LOSS[1], fit_R$LOSS)
expect_equal(fit_C$Y_HAT[, , 1], fit_R$Y_HAT[[1]], tolerance = tl)
expect_equal(fit_C$Y_HAT[[1]], fit_R$Y_HAT[[1]], tolerance = tl)
expect_identical(fit_C$gg, fit_R$gg)
})

0 comments on commit d72c8df

Please sign in to comment.