diff --git a/R/CreateInputsModel.R b/R/CreateInputsModel.R index 914d61f6a7f1524afdcb27cecf8c247543cc62cc..4fba2e85ffaa9214d6e7c72c356f25c02da2b54d 100644 --- a/R/CreateInputsModel.R +++ b/R/CreateInputsModel.R @@ -10,29 +10,29 @@ CreateInputsModel <- function(FUN_MOD, ObjectClass <- NULL - FUN_MOD <- match.fun(FUN_MOD) + ## check DatesR + if (is.null(DatesR)) { + stop("'DatesR' is missing") + } + if (!"POSIXlt" %in% class(DatesR) & !"POSIXct" %in% class(DatesR)) { + stop("'DatesR' must be defined as 'POSIXlt' or 'POSIXct'") + } + if (!"POSIXlt" %in% class(DatesR)) { + DatesR <- as.POSIXlt(DatesR) + } + if (any(duplicated(DatesR))) { + stop("'DatesR' must not include duplicated values") + } + LLL <- length(DatesR) - ##check_FUN_MOD + ## check FUN_MOD + FUN_MOD <- match.fun(FUN_MOD) FeatFUN_MOD <- .GetFeatModel(FUN_MOD = FUN_MOD, DatesR = DatesR) ObjectClass <- FeatFUN_MOD$Class ##check_arguments - if ("GR" %in% ObjectClass | "CemaNeige" %in% ObjectClass) { - if (is.null(DatesR)) { - stop("'DatesR' is missing") - } - if (!"POSIXlt" %in% class(DatesR) & !"POSIXct" %in% class(DatesR)) { - stop("'DatesR' must be defined as 'POSIXlt' or 'POSIXct'") - } - if (!"POSIXlt" %in% class(DatesR)) { - DatesR <- as.POSIXlt(DatesR) - } - if (any(duplicated(DatesR))) { - stop("'DatesR' must not include duplicated values") - } - LLL <- length(DatesR) - } + if ("GR" %in% ObjectClass) { if (is.null(Precip)) { stop("Precip is missing")