Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: importing %do% in fun header + some reformatting #18

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions R/stics_wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
#'
#' @export
#'
#' @importFrom foreach %dopar%
#' @importFrom foreach %dopar% %do%
#' @importFrom parallel clusterCall makeCluster stopCluster
#' @importFrom doParallel registerDoParallel
#' @importFrom magrittr %>%
Expand Down Expand Up @@ -181,8 +181,12 @@
registerDoParallel(cl)
clusterCall(cl, function(x) .libPaths(x), .libPaths())

`%doparornot%` <- `%dopar%`
} else `%doparornot%` <- `%do%`
#`%doparornot%` <- `%dopar%`
`%do_par_or_not%` <- `%dopar%`

Check warning on line 185 in R/stics_wrapper.R

View check run for this annotation

Codecov / codecov/patch

R/stics_wrapper.R#L185

Added line #L185 was not covered by tests
} else {
#`%doparornot%` <- `%do%`
`%do_par_or_not%` <- `%do%`

Check warning on line 188 in R/stics_wrapper.R

View check run for this annotation

Codecov / codecov/patch

R/stics_wrapper.R#L188

Added line #L188 was not covered by tests
}

# Define the list of USMs to simulate and initialize results -----------------
# Check the available USMs
Expand Down Expand Up @@ -282,7 +286,8 @@
i = seq_along(sit2simulate),
.export = c("run_stics", "select_results"),
.packages = c("SticsRFiles")
) %doparornot% {
#) %doparornot% {
) %do_par_or_not% {

Check warning on line 290 in R/stics_wrapper.R

View check run for this annotation

Codecov / codecov/patch

R/stics_wrapper.R#L290

Added line #L290 was not covered by tests
## Loops on the USMs that can be simulated
## out is a list containing vectors of:
## o list of simulated outputs,
Expand Down Expand Up @@ -641,7 +646,7 @@
req_var_names <- c(var_names)
}

## Convert required variables names to Stics variables names (i.e. handle ())
## Convert required variables names to Stics variables names (i.e. handle ())
req_var_names <- SticsRFiles:::var_to_col_names(req_var_names)

## Add reserved keywords "Plant" and "Date" from the list
Expand All @@ -653,8 +658,8 @@
inter_var_names <- sim_var_names[req_vars_idx]


## In case some variables are not simulated, warn the user, add them in var.mod
## and re-simulate or select the results if var.mod has already been modified.
## In case some variables are not simulated, warn the user, add them in var.mod
## and re-simulate or select the results if var.mod has already been modified.
if (length(inter_var_names) < length(req_var_names)) {
if (varmod_modified) {
## var.mod has already been modified ... warn the user the required
Expand All @@ -668,7 +673,7 @@
"not simulated by the Stics model for USM",
situation,
"although added in", file.path(run_dir, "var.mod"),
"=> these variables may not be Stics variables, please check spelling. \n ",
"=> these variables may not be Stics variables, please check spelling. \n ",

Check warning on line 676 in R/stics_wrapper.R

View check run for this annotation

Codecov / codecov/patch

R/stics_wrapper.R#L676

Added line #L676 was not covered by tests
"Simulated variables:", paste(sim_var_names, collapse = ", ")
))
res$flag_error <- FALSE
Expand Down
Loading