Commit bd42c74a authored by Dorchies David's avatar Dorchies David
Browse files

fix(CreateInputsCrit_DeLavenne): inapropriate error message for wrong length of parameter AprParam

Refs #"111
Showing with 15 additions and 0 deletions
+15 -0
...@@ -26,6 +26,10 @@ CreateInputsCrit_DeLavenne <- function(FUN_CRIT = ErrorCrit_KGE, ...@@ -26,6 +26,10 @@ CreateInputsCrit_DeLavenne <- function(FUN_CRIT = ErrorCrit_KGE,
if (!is.null(epsilon) && !is.numeric(epsilon)) { if (!is.null(epsilon) && !is.numeric(epsilon)) {
stop("'epsilon' must be numeric") stop("'epsilon' must be numeric")
} }
if (!is.numeric(AprParamR) || length(AprParamR) != RunOptions$FeatFUN_MOD$NbParam) {
stop("'AprParamR' must be a numeric vector of length ",
RunOptions$FeatFUN_MOD$NbParam)
}
FUN_TRANSFO <- .FunTransfo(RunOptions$FeatFUN_MOD) FUN_TRANSFO <- .FunTransfo(RunOptions$FeatFUN_MOD)
......
...@@ -38,3 +38,14 @@ test_that("should return KGE*(1-k)+k with parameters matching a priori parameter ...@@ -38,3 +38,14 @@ test_that("should return KGE*(1-k)+k with parameters matching a priori parameter
ErrorCrit(IC_DL, OutputsModel)$CritValue) ErrorCrit(IC_DL, OutputsModel)$CritValue)
}) })
test_that("should return proper error if mismatch number of parameters", {
expect_error(
CreateInputsCrit_DeLavenne(FUN_CRIT = ErrorCrit_KGE,
InputsModel = InputsModel,
RunOptions = RunOptions,
Obs = BasinObs$Qmm[Ind_Run],
AprParamR = Param[-1],
k = k),
regex = "'AprParamR' must be a numeric vector of length 4"
)
})
Supports Markdown
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