From aa97caf77a1dbc69cd534efb340f26f05077f1c9 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Tue, 17 Sep 2024 17:07:42 +0200 Subject: [PATCH] Added TODOs and FIXMEs (#11) --- src/func_MCMC_graph_cpp.cpp | 4 ++-- tests/testthat/test-cpp_translation.R | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/func_MCMC_graph_cpp.cpp b/src/func_MCMC_graph_cpp.cpp index 039456e..ed26735 100644 --- a/src/func_MCMC_graph_cpp.cpp +++ b/src/func_MCMC_graph_cpp.cpp @@ -26,7 +26,7 @@ arma::mat construct_G_MRF(arma::mat G, arma::vec b, uint S, int p, bool MRF_2b) } } else { // one value for b in MRF prior for all subgraphs - G_MRF = b[0] * G; + G_MRF = b[0] * G; // TODO: replace [] with () for bound check } return G_MRF; } @@ -58,7 +58,7 @@ Rcpp::List func_MCMC_graph_cpp( Rcpp::List C = Rcpp::as(ini["C.ini"]); Rcpp::List gamma_ini_list = Rcpp::as(ini["gamma.ini"]); - arma::vec gamma_ini = Rcpp::as(gamma_ini_list[0]); // TODO: Test for S > 1, not sure the results are correct. + arma::vec gamma_ini = Rcpp::as(gamma_ini_list[0]); // FIXME: use list_to_matrix() and change with S if (MRF_2b) { // two different values for b in MRF prior for subgraphs G_ss and G_rs diff --git a/tests/testthat/test-cpp_translation.R b/tests/testthat/test-cpp_translation.R index 2bfac6d..a01c310 100644 --- a/tests/testthat/test-cpp_translation.R +++ b/tests/testthat/test-cpp_translation.R @@ -29,7 +29,6 @@ hyperPooled = list( ) hyperPooled_2S <- hyperPooled hyperPooled_2S$G <- Matrix::bdiag(simData$G, simData$G) -hyperPooled_2S$b <- c(0.1, 0.2) # Run a 'Pooled' Bayesian Cox model with graphical learning @@ -39,7 +38,10 @@ BayesSurvive_wrap <- function( MRF_G = TRUE, MRF_2b = FALSE, verbose = FALSE ) { if (!MRF_G) { - if (!is.null(names(data))) data <- list(data) + if (!is.null(names(data))) { + data <- list(data) + # hyper$b <- c(0.1, 0.2) # TODO: uncomment for !MRF_2b cases + } hyper$lambda <- 3 # TODO: mandatory for !MRG.G? Add validation! hyper$nu0 <- 0.05 hyper$nu1 <- 5 @@ -59,8 +61,9 @@ fit_C_noMRFG <- BayesSurvive_wrap(data, initial, hyperPooled, MRF_G = FALSE, use fit_R_2b <- BayesSurvive_wrap(data, initial, hyperPooled, MRF_2b = TRUE) fit_C_2b <- BayesSurvive_wrap(data, initial, hyperPooled, MRF_2b = TRUE, use_cpp = TRUE) fit_R_2b_no_G <- BayesSurvive_wrap(data_2S, initial, hyperPooled_2S, MRF_2b = TRUE, MRF_G = FALSE, n_iter = 2L) -# fit_C_2b_no_G <- BayesSurvive_wrap(data_2S, initial, hyperPooled_2S, MRF_2b = TRUE, MRF_G = FALSE, use_cpp = TRUE, n_iter = 2L) // FIXME: broken +# fit_C_2b_no_G <- BayesSurvive_wrap(data_2S, initial, hyperPooled_2S, MRF_2b = TRUE, MRF_G = FALSE, use_cpp = TRUE, n_iter = 2L) # FIXME: broken +# TODO: reduce. Takes 4 minutes! # TODO: reorganize tests so that they come right after each fit_R/fit_C pair test_that("R and C++ objects are similar", { expect_equal(fit_R$call, fit_C$call)