Skip to content

Commit

Permalink
Merge branch '152-createinputsmodel-specify-the-error-message-qobs-co…
Browse files Browse the repository at this point in the history
…lumn-names-must-be-included-in-id-s-of-the' into 'dev'

Resolve "CreateInputsModel: Specify the error message: "'Qobs' column names must be included in 'id's of the GRiwrm object""

Closes #152

See merge request in-wop/airGRiwrm!95
  • Loading branch information
Dorchies David committed Jul 31, 2024
2 parents 0652f51 + 222e64a commit 832876f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion R/CreateInputsModel.GRiwrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ CreateInputsModel.GRiwrm <- function(x, DatesR,
stop(sprintf(
"'%s' column names must be included in 'id's of the GRiwrm object",
varName
))
), "\n",
sprintf("These columns are not known: %s",
paste(colnames(v)[!colnames(v) %in% x$id], collapse = ", ")))
} else if (any(duplicated(colnames(v)))) {
stop(sprintf(
"'%s' has duplicated column names: '%s'",
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/helper_cemaneige.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' @examples
setUpCemaNeigeData <- function() {

data(L0123001)
data(L0123001, package = "airGR", envir = environment())

# Formatting observations for the hydrological models
# Each input data should be a matrix or a data.frame with the good id in the name of the column
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-CreateInputsModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test_that("throws error on wrong column name", {
TempMean = l$TempMean,
ZInputs = l$ZInputs,
HypsoData = l$HypsoData),
regexp = "column names must be included in")
regexp = "column names must be included in.*Up0")
colnames(l$Precip) <- NULL
expect_error(CreateInputsModel(l$griwrm,
DatesR = l$DatesR,
Expand Down

0 comments on commit 832876f

Please sign in to comment.