Commit ec8c492e authored by Daniela Rabe's avatar Daniela Rabe
Browse files

Merge branch 'progressbar' into 'master'

update Progressbar

See merge request !27
parents d7702099 673218ee
Pipeline #26237 passed with stages
in 7 minutes and 42 seconds
......@@ -19,7 +19,8 @@
#' @param save_runs if the user wants to save the runs, if TRUE the complete Habitat Class object is returned
#' @param parallel_mode run loops in parallel
#' @param max_num_cores maximum number of cores for parallelism
#' @param progress_bar if true use a normal progress bar, otherwise a shiny's progress bar
#' @param progress_bar if true use a normal progress bar, otherwise a shiny progress bar
#' @param session shiny session, needed for progress bar update
#'
#' @return a list with 5 elements:
#' 1) returns 0 succeeded, 1 increase init.samples, or 2 increase init.samples and nb_models
......@@ -57,7 +58,8 @@ sample_nb <- function(raster,
save_runs,
parallel_mode,
max_num_cores,
progress_bar = TRUE) {
progress_bar = TRUE,
session) {
print(paste(paste("init.samples = ", nb_samples[1]),
paste("models = ", nb_mean)))
###
......@@ -153,9 +155,12 @@ sample_nb <- function(raster,
if (progress_bar) {
setTxtProgressBar(pb, k)
} else {
shinybusy::update_modal_progress(
value = k / (nb_mean + nrow(reference)),
text = paste("Doing sampling for model", k)
shinyWidgets::updateProgressBar(
session = session,
id = "pbar",
value = k,
total = nb_mean,
title = paste("Doing sampling for model", k)
)
}
}
......@@ -226,10 +231,13 @@ sample_nb <- function(raster,
}
m[l] <- max(dif[2,], na.rm = T)
if (!progress_bar) {
shinybusy::update_modal_progress(
value = (nb_mean+jj) / (nb_mean + nrow(reference)),
text = paste("Doing prediction for class", jj)
)
shinyWidgets::updateProgressBar(
session = session,
id = "pbar",
value = jj,
total = nrow(reference),
title = paste("Doing prediction for class", jj)
)
}
}
index <- which.max(dif[2,])
......
......@@ -22,7 +22,8 @@ sample_nb(
save_runs,
parallel_mode,
max_num_cores,
progress_bar = TRUE
progress_bar = TRUE,
session
)
}
\arguments{
......@@ -58,7 +59,9 @@ sample_nb(
\item{max_num_cores}{maximum number of cores for parallelism}
\item{progress_bar}{if true use a normal progress bar, otherwise a shiny's progress bar}
\item{progress_bar}{if true use a normal progress bar, otherwise a shiny progress bar}
\item{session}{shiny session, needed for progress bar update}
\item{nb_models}{number of models (independent classifiers) to collect}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment