diff --git a/NEWS.md b/NEWS.md index 19398906..3b41e5e8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,9 @@ BUGFIXES : -* `setSimulationPathAPI()` error message with bad id +* `setSimulationPathAPI()` : + - returns an API exception if the requested study ID is incorrect + - `simulation` the simulation parameter works with negative values within the limit of the number of simulations * correction in `readClusterDesc()` calls to add "opts" diff --git a/R/setSimulationPath.R b/R/setSimulationPath.R index e7971887..5df538e3 100644 --- a/R/setSimulationPath.R +++ b/R/setSimulationPath.R @@ -246,8 +246,13 @@ setSimulationPath <- function(path, simulation = NULL) { .giv_sim <- function(simulation, simNames, path){ if (is.numeric(simulation)) { - if (simulation > 0) sim <- simNames[simulation] - else sim <- rev(simNames)[abs(simulation)] + if(abs(simulation)>length(simNames)) + stop(paste0("Parameter 'simulation' is greater than + the number of simulations (", length(simNames), ")"), call. = FALSE) + if (simulation > 0) + sim <- simNames[simulation] + else + sim <- rev(simNames)[abs(simulation)] } else { if (any(simNames == simulation)) sim <- simulation else { diff --git a/R/utils_api.R b/R/utils_api.R index 75e38dba..921e2715 100644 --- a/R/utils_api.R +++ b/R/utils_api.R @@ -47,7 +47,7 @@ read_secure_json <- function(url, token = NULL, timeout = 60, config = list()) { outputPath <- file.path(path, "output") if(is.null(simulation) | (!is.null(simulation) && !simulation %in% c(0, "input"))){ outputContent <- names(read_secure_json(paste0(outputPath, "&depth=4"), ...)) - simNames <- setdiff(basename(outputContent), "maps") + simNames <- setdiff(basename(outputContent), c("maps", "logs")) } if (length(simNames) == 0) { if (length(simulation) > 0 && !simulation %in% c(0, "input")) { @@ -196,6 +196,7 @@ read_secure_json <- function(url, token = NULL, timeout = 60, config = list()) { simDataPath = simDataPath, name = as.character(info$name), mode = as.character(info$mode), + simDate = info$date, synthesis = synthesis, yearByYear = yearByYear, scenarios = scenarios,