diff --git a/tests/testthat/test_cla_secsse_ml_func_def_pars.R b/tests/testthat/test_cla_secsse_ml_func_def_pars.R index 13b318b..a141a56 100644 --- a/tests/testthat/test_cla_secsse_ml_func_def_pars.R +++ b/tests/testthat/test_cla_secsse_ml_func_def_pars.R @@ -42,7 +42,7 @@ test_that("multiplication works", { cond <- 'proper_cond' root_state_weight <- 'proper_weights' sampling_fraction <- c(1, 1, 1) - model <- expect_message(expect_warning(cla_secsse_ml_func_def_pars( + model <- expect_warning(cla_secsse_ml_func_def_pars( phylotree, traits, num_concealed_states, @@ -63,7 +63,7 @@ test_that("multiplication works", { optimmethod, num_cycles = 1, verbose = 0 - ))) + )) expect_equal(model$ML, -136.5926599) expect_length(model, 3) diff --git a/tests/testthat/test_hisse.R b/tests/testthat/test_hisse.R index a964af0..b366752 100644 --- a/tests/testthat/test_hisse.R +++ b/tests/testthat/test_hisse.R @@ -26,6 +26,8 @@ test_that("secsse gives the same result as hisse", { root_state_weight <- "maddison_weights" cond <- "noCondit" + testthat::expect_warning( + y <- secsse_loglik(parameter = toCheck, phy = phy, traits = traits, @@ -33,7 +35,10 @@ test_that("secsse gives the same result as hisse", { cond = cond, root_state_weight = root_state_weight, sampling_fraction = sampling_fraction) + + ) cond <- "maddison_cond" + testthat::expect_warning( y1 <- round(as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, @@ -43,12 +48,13 @@ test_that("secsse gives the same result as hisse", { root_state_weight = root_state_weight, sampling_fraction = sampling_fraction) ), 4) + ) ## Now with different sampling_fraction sampling_fraction <- c(0.8, 1) - y2 <- round(as.numeric(secsse_loglik(parameter = toCheck, + y2 <- testthat::expect_warning(round(as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, num_concealed_states = @@ -56,7 +62,7 @@ test_that("secsse gives the same result as hisse", { cond = cond, root_state_weight = root_state_weight, sampling_fraction = sampling_fraction) - ), 4) + ), 4)) testthat::expect_equal(-237.8611, y1, tolerance = 0.001) testthat::expect_equal(-243.8611, y2, tolerance = 0.001) @@ -65,14 +71,15 @@ test_that("secsse gives the same result as hisse", { .Platform$OS.type == "windows") { testthat::skip_on_cran() - z4 <- as.numeric(secsse_loglik(parameter = toCheck, + z4 <- testthat::expect_warning( + as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, num_concealed_states = num_concealed_states, cond = cond, root_state_weight = root_state_weight, sampling_fraction = sampling_fraction, - num_threads = 4)) + num_threads = 4))) testthat::expect_equal(y2, z4, tolerance = 1e-4) # is different LL, diff 0.0118 } diff --git a/tests/testthat/test_integration_methods.R b/tests/testthat/test_integration_methods.R index aac6819..bd4aea0 100644 --- a/tests/testthat/test_integration_methods.R +++ b/tests/testthat/test_integration_methods.R @@ -16,7 +16,7 @@ test_that("loglik for different integrators", { root_state_weight <- "maddison_weights" cond <- "noCondit" - loglik1 <- as.numeric(secsse_loglik(parameter = toCheck, + loglik1 <- testthat::expect_warning(as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, num_concealed_states = @@ -24,14 +24,14 @@ test_that("loglik for different integrators", { cond = cond, root_state_weight = root_state_weight, sampling_fraction = sampling_fraction) - ) + )) for (integ_method in c("odeint::runge_kutta_cash_karp54", "odeint::runge_kutta_fehlberg78", "odeint::runge_kutta_dopri5", "odeint::bulirsch_stoer", "odeint::runge_kutta4")) { - loglik2 <- as.numeric(secsse_loglik(parameter = toCheck, + loglik2 <- testthat::expect_warning(as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, num_concealed_states = @@ -39,7 +39,7 @@ test_that("loglik for different integrators", { cond = cond, root_state_weight = root_state_weight, sampling_fraction = sampling_fraction, - method = integ_method)) + method = integ_method))) testthat::expect_equal(loglik1, loglik2) } }) \ No newline at end of file diff --git a/tests/testthat/test_plotting.R b/tests/testthat/test_plotting.R index 48dd646..069065d 100644 --- a/tests/testthat/test_plotting.R +++ b/tests/testthat/test_plotting.R @@ -14,7 +14,7 @@ test_that("normal plotting", { helper_function <- function(x) { return(sum(x[c(5, 7)]) / sum(x)) # normalized by total sum, just in case. } - testthat::expect_message( + testthat::expect_warning( px <- plot_state_exact(parameters = params, phy = phy, traits = traits, @@ -57,7 +57,6 @@ test_that("cla plotting", { root_state_weight <- "proper_weights" sampling_fraction <- c(1, 1, 1) - testthat::expect_message( testthat::expect_warning( model_R <- cla_secsse_ml( phylotree, @@ -76,13 +75,13 @@ test_that("cla plotting", { optimmethod, num_cycles = 1, verbose = FALSE) - )) + ) helper_function <- function(x) { return(sum(x[c(10, 13, 16)]) / sum(x)) } - testthat::expect_message( + testthat::expect_warning( px <- secsse::plot_state_exact(parameters = model_R$MLpars, phy = phylotree, traits = traits, diff --git a/tests/testthat/test_secsse_ct.R b/tests/testthat/test_secsse_ct.R index e379365..aefde89 100644 --- a/tests/testthat/test_secsse_ct.R +++ b/tests/testthat/test_secsse_ct.R @@ -17,7 +17,8 @@ test_that("the loglik for the complete tree", { root_state_weight <- "maddison_weights" cond <- "noCondit" - loglik1 <- as.numeric(secsse_loglik(parameter = toCheck, + loglik1 <- testthat::expect_warning( + as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, num_concealed_states = @@ -26,8 +27,9 @@ test_that("the loglik for the complete tree", { root_state_weight = root_state_weight, sampling_fraction = sampling_fraction, is_complete_tree = TRUE) - ) - loglik2 <- as.numeric(secsse_loglik(parameter = toCheck, + )) + loglik2 <- testthat::expect_warning( + as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, num_concealed_states = @@ -35,6 +37,7 @@ test_that("the loglik for the complete tree", { cond = cond, root_state_weight = root_state_weight, sampling_fraction = sampling_fraction) + ) ) # check that the likelihood for a specifically complete tree without # extinct lineages with 0 extinction @@ -43,7 +46,7 @@ test_that("the loglik for the complete tree", { testthat::expect_equal(loglik1, loglik2) toCheck[[2]][] <- 0.05 - loglik3 <- as.numeric(secsse_loglik(parameter = toCheck, + loglik3 <- testthat::expect_warning(as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, num_concealed_states = @@ -51,9 +54,9 @@ test_that("the loglik for the complete tree", { cond = cond, root_state_weight = root_state_weight, sampling_fraction = sampling_fraction, - is_complete_tree = TRUE) + is_complete_tree = TRUE)) ) - loglik4 <- as.numeric(secsse_loglik(parameter = toCheck, + loglik4 <- testthat::expect_warning(as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, num_concealed_states = @@ -61,7 +64,7 @@ test_that("the loglik for the complete tree", { cond = cond, root_state_weight = root_state_weight, sampling_fraction = sampling_fraction, - is_complete_tree = FALSE) + is_complete_tree = FALSE)) ) # check that when the extinction rate is not zero, # the likelihood of treating the tree as @@ -79,7 +82,7 @@ test_that("the loglik for the complete tree", { # out <- DDD::dd_sim(pars = c(0.4, 0.1, 40), age = 15) # phy <- out$tas # traits <- sample(c(0,1),ape::Ntip(phy),replace = T) - loglik5 <- as.numeric(secsse_loglik(parameter = toCheck, + loglik5 <- testthat::expect_warning(as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, num_concealed_states = @@ -87,7 +90,7 @@ test_that("the loglik for the complete tree", { cond = cond, root_state_weight = root_state_weight, sampling_fraction = sampling_fraction, - is_complete_tree = TRUE)) + is_complete_tree = TRUE))) testthat::expect_equal(loglik5, -303.4003, tolerance = 1E-4) # TJ: hardcoded modified LL @@ -101,7 +104,7 @@ test_that("the loglik for the complete tree", { parameter <- toCheck parameter[[1]] <- lambdas - loglik7 <- secsse_loglik(parameter = parameter, + loglik7 <- testthat::expect_warning(secsse_loglik(parameter = parameter, phy = phy, traits = traits, num_concealed_states = num_concealed_states, @@ -111,13 +114,13 @@ test_that("the loglik for the complete tree", { setting_calculation = NULL, see_ancestral_states = FALSE, loglik_penalty = 0, - is_complete_tree = TRUE) + is_complete_tree = TRUE)) testthat::expect_equal(loglik7, loglik5) # not true ? # Parallel code doesn't work on CI skip_on_cran() skip_on_ci() - loglik6 <- as.numeric(secsse_loglik(parameter = toCheck, + loglik6 <- testthat::expect_warning(as.numeric(secsse_loglik(parameter = toCheck, phy = phy, traits = traits, num_concealed_states = @@ -126,10 +129,10 @@ test_that("the loglik for the complete tree", { root_state_weight = root_state_weight, sampling_fraction = sampling_fraction, is_complete_tree = TRUE, - num_threads = 4)) + num_threads = 4))) testthat::expect_equal(loglik6, loglik5, tolerance = 1E-4) - loglik8 <- secsse_loglik(parameter = parameter, + loglik8 <- testthat::expect_warning(secsse_loglik(parameter = parameter, phy = phy, traits = traits, num_concealed_states = num_concealed_states, @@ -137,6 +140,6 @@ test_that("the loglik for the complete tree", { root_state_weight = root_state_weight, sampling_fraction = sampling_fraction, is_complete_tree = TRUE, - num_threads = 4) + num_threads = 4)) testthat::expect_equal(loglik8, loglik7, tolerance = 1e-5) }) diff --git a/tests/testthat/test_secsse_sim.R b/tests/testthat/test_secsse_sim.R index b19a096..bd4b985 100644 --- a/tests/testthat/test_secsse_sim.R +++ b/tests/testthat/test_secsse_sim.R @@ -27,7 +27,6 @@ test_that("test secsse_sim", { root_state_weight <- "proper_weights" sampling_fraction <- c(1, 1, 1) - testthat::expect_message( testthat::expect_warning( model_R <- secsse::cla_secsse_ml( phylotree, @@ -46,7 +45,7 @@ test_that("test secsse_sim", { optimmethod, num_cycles = 1, verbose = FALSE) - )) + ) qs <- model_R$MLpars[[3]] diag(qs) <- 0