From b25705002e9ea21f440a4b073256f292a308182e Mon Sep 17 00:00:00 2001 From: Josh Yamamoto Date: Thu, 8 Feb 2024 17:19:58 -0700 Subject: [PATCH] removing unorthdox console output printing --- DESCRIPTION | 6 ++---- R/saeczi.R | 28 +--------------------------- src/helpers.cpp | 8 +------- 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e6390e0..a9706ef 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,8 +27,7 @@ Imports: future, methods, rlang, - Rcpp, - cli + Rcpp RoxygenNote: 7.3.1 Suggests: testthat (>= 3.0.0) @@ -37,5 +36,4 @@ Depends: R (>= 4.1.0) LinkingTo: Rcpp, - RcppEigen, - cli + RcppEigen \ No newline at end of file diff --git a/R/saeczi.R b/R/saeczi.R index c6a44ed..7b2744a 100644 --- a/R/saeczi.R +++ b/R/saeczi.R @@ -53,11 +53,6 @@ saeczi <- function(samp_dat, message("See for reference on how to use `future::plan()`") } - w <- options("width")$width - header <- paste0(rep("=", w), collapse = "") - cat(cli::make_ansi_style("steelblue")(header), "\n", sep = "") - cat(cli::style_bold(cli::col_black("\u2022 Fitting Models..."))) - cat("\n") # creating strings of original X, Y names Y <- deparse(lin_formula[[2]]) @@ -96,9 +91,6 @@ saeczi <- function(samp_dat, if (mse_est) { - cat(cli::style_bold(cli::col_black("\u2022 Beginning Bootstrap..."))) - cat("\n") - zi_model_coefs <- mse_coefs( original_out$lmer, original_out$glmer @@ -218,9 +210,6 @@ saeczi <- function(samp_dat, p <- progressor(steps = length(x)) - cat("creating bootstraps...") - cat("\n") - res <- furrr::future_map(.x = boot_lst, .f = \(.x) { @@ -252,8 +241,6 @@ saeczi <- function(samp_dat, # down to positive response values u_lm[is.na(u_lm)] <- 0 - cat("estimating mse...") - cat("\n") preds_full <- generate_mse(.data = boot_pop_data, truth = boot_truth, domain_level = domain_level, @@ -279,9 +266,7 @@ saeczi <- function(samp_dat, }) } else { - task_text <- " - Fitting to Bootstrap samples" - task_done <- paste0(task_text, cli::make_ansi_style("green4")(" \u2713")) - reset <- paste0(rep(" ", nchar(task_text)), collapse = " ") + res <- purrr::map(.x = boot_samp_ls, .f = \(.x) { @@ -292,11 +277,8 @@ saeczi <- function(samp_dat, }, .progress = list( type = "iterator", - format = " - Fitting to Bootstrap samples {cli::pb_percent}", clear = TRUE )) - - cat("\r", reset, "\r", " ", task_done, "\n", sep = "") beta_lm_mat <- res |> map_dfr(.f = ~ .x$params$beta_lm) |> @@ -318,9 +300,6 @@ saeczi <- function(samp_dat, # down to positive response values u_lm[is.na(u_lm)] <- 0 - task_text <- " - Estimating MSE" - task_done <- paste0(task_text, cli::make_ansi_style("green4")(" \u2713")) - reset <- paste0(rep(" ", nchar(task_text)), collapse = " ") preds_full <- generate_mse(.data = boot_pop_data, truth = boot_truth, domain_level = domain_level, @@ -331,7 +310,6 @@ saeczi <- function(samp_dat, lin_X = lin_X, log_X = log_X) - cat("\r", reset, "\r", " ", task_done, "\n", sep = "") log_lst <- res |> map(.f = ~ .x$log) @@ -339,9 +317,6 @@ saeczi <- function(samp_dat, } - cat(cli::style_bold(cli::col_black("\u2022 Compiling Results..."))) - cat("\n") - Sys.sleep(0.5) final_df <- setNames( boot_res[[1]], c("domain", "mse") @@ -376,7 +351,6 @@ saeczi <- function(samp_dat, lin_mod = original_out$lmer, log_mod = original_out$glmer ) - cat(cli::make_ansi_style("steelblue")(header), "\n", sep = "") structure(out, class = "zi_mod") diff --git a/src/helpers.cpp b/src/helpers.cpp index 624f4e4..f03491e 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -3,7 +3,6 @@ #include #include #include -#include double sigmoid(double x) { return 1.0 / (1.0 + std::exp(-x)); @@ -21,8 +20,6 @@ SEXP dom_preds_calc(const Eigen::MatrixXd &beta_lm, Eigen::MatrixXd result = Eigen::MatrixXd::Zero(J, B); - SEXP bar = PROTECT(cli_progress_bar(J, NULL)); - cli_progress_set_format(bar, " - Estimating MSE {cli::pb_percent}"); for (int j = 0; j < J; ++j) { Rcpp::List dmats_j = design_mats[j]; @@ -41,12 +38,9 @@ SEXP dom_preds_calc(const Eigen::MatrixXd &beta_lm, Eigen::MatrixXd dom_preds_j = unit_preds_j.colwise().mean(); result.block(j, 0, 1, B) = dom_preds_j; - if (CLI_SHOULD_TICK) cli_progress_set(bar, j); } - cli_progress_set_clear(bar, 1); - cli_progress_done(bar); - UNPROTECT(1); + return Rcpp::wrap(result); }