From a5ad9a3372f9e3bd6ef8e89e34f852673a819e7f Mon Sep 17 00:00:00 2001 From: Delaigue Olivier <olivier.delaigue@irstea.priv> Date: Mon, 1 Apr 2019 09:23:36 +0200 Subject: [PATCH] v1.2.12.19 BUG: checks on FUN_MOD modified in CreateIniStates to avoid errors generated by the use of match.fun --- DESCRIPTION | 2 +- NEWS.rmd | 2 +- R/CreateIniStates.R | 25 +++++++++++++------------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 317e825e..5d4ba682 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.2.12.18 +Version: 1.2.12.19 Date: 2019-04-01 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), diff --git a/NEWS.rmd b/NEWS.rmd index 4cf44a54..81d6e227 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -13,7 +13,7 @@ output: -### 1.2.12.18 Release Notes (2019-04-01) +### 1.2.12.19 Release Notes (2019-04-01) diff --git a/R/CreateIniStates.R b/R/CreateIniStates.R index 234802e7..989b3426 100644 --- a/R/CreateIniStates.R +++ b/R/CreateIniStates.R @@ -10,7 +10,8 @@ CreateIniStates <- function(FUN_MOD, InputsModel, UH1n <- 20L UH2n <- UH1n * 2L - + + nameFUN_MOD <- as.character(substitute(FUN_MOD)) FUN_MOD <- match.fun(FUN_MOD) ## check FUN_MOD @@ -70,7 +71,7 @@ CreateIniStates <- function(FUN_MOD, InputsModel, } } else if (!is.null(ExpStore)) { if (verbose) { - warning(sprintf("'%s' does not require 'ExpStore'. Value set to NA", as.character(substitute(FUN_MOD)))) + warning(sprintf("'%s' does not require 'ExpStore'. Value set to NA", nameFUN_MOD)) } ExpStore <- Inf } @@ -78,13 +79,13 @@ CreateIniStates <- function(FUN_MOD, InputsModel, if (identical(FUN_MOD, RunModel_GR2M)) { if (!is.null(UH1)) { if (verbose) { - warning(sprintf("'%s' does not require 'UH1'. Values set to NA", as.character(substitute(FUN_MOD)))) + warning(sprintf("'%s' does not require 'UH1'. Values set to NA", nameFUN_MOD)) } UH1 <- rep(Inf, UH1n) } if (!is.null(UH2)) { if (verbose) { - warning(sprintf("'%s' does not require 'UH2'. Values set to NA", as.character(substitute(FUN_MOD)))) + warning(sprintf("'%s' does not require 'UH2'. Values set to NA", nameFUN_MOD)) } UH2 <- rep(Inf, UH2n) } @@ -92,7 +93,7 @@ CreateIniStates <- function(FUN_MOD, InputsModel, if ((identical(FUN_MOD, RunModel_GR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J)) & !is.null(UH1)) { if (verbose) { - warning(sprintf("'%s' does not require 'UH1'. Values set to NA", as.character(substitute(FUN_MOD)))) + warning(sprintf("'%s' does not require 'UH1'. Values set to NA", nameFUN_MOD)) } UH1 <- rep(Inf, UH1n) } @@ -100,43 +101,43 @@ CreateIniStates <- function(FUN_MOD, InputsModel, if ("CemaNeige" %in% ObjectClass & ! "GR" %in% ObjectClass) { if (!is.null(ProdStore)) { if (verbose) { - warning(sprintf("'%s' does not require 'ProdStore'. Values set to NA", as.character(substitute(FUN_MOD)))) + warning(sprintf("'%s' does not require 'ProdStore'. Values set to NA", nameFUN_MOD)) } } ProdStore <- Inf if (!is.null(RoutStore)) { if (verbose) { - warning(sprintf("'%s' does not require 'RoutStore'. Values set to NA", as.character(substitute(FUN_MOD)))) + warning(sprintf("'%s' does not require 'RoutStore'. Values set to NA", nameFUN_MOD)) } } RoutStore <- Inf if (!is.null(ExpStore)) { if (verbose) { - warning(sprintf("'%s' does not require 'ExpStore'. Values set to NA", as.character(substitute(FUN_MOD)))) + warning(sprintf("'%s' does not require 'ExpStore'. Values set to NA", nameFUN_MOD)) } } ExpStore <- Inf if (!is.null(UH1)) { if (verbose) { - warning(sprintf("'%s' does not require 'UH1'. Values set to NA", as.character(substitute(FUN_MOD)))) + warning(sprintf("'%s' does not require 'UH1'. Values set to NA", nameFUN_MOD)) } } UH1 <- rep(Inf, UH1n) if (!is.null(UH2)) { if (verbose) { - warning(sprintf("'%s' does not require 'UH2'. Values set to NA", as.character(substitute(FUN_MOD)))) + warning(sprintf("'%s' does not require 'UH2'. Values set to NA", nameFUN_MOD)) } } UH2 <- rep(Inf, UH2n) } if("CemaNeige" %in% ObjectClass & (is.null(GCemaNeigeLayers) | is.null(eTGCemaNeigeLayers))) { - stop("'RunModel_CemaNeigeGR*' need values for 'GCemaNeigeLayers' and 'GCemaNeigeLayers'") + stop(sprintf("'%s' need values for 'GCemaNeigeLayers' and 'GCemaNeigeLayers'", nameFUN_MOD)) } if(!"CemaNeige" %in% ObjectClass & (!is.null(GCemaNeigeLayers) | !is.null(eTGCemaNeigeLayers))) { if (verbose) { - warning(sprintf("'%s' does not require 'GCemaNeigeLayers' and 'GCemaNeigeLayers'. Values set to NA", as.character(substitute(FUN_MOD)))) + warning(sprintf("'%s' does not require 'GCemaNeigeLayers' and 'GCemaNeigeLayers'. Values set to NA", nameFUN_MOD)) } GCemaNeigeLayers <- Inf eTGCemaNeigeLayers <- Inf -- GitLab