Commit 05cf434b authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.6.9.3 refactor: '['.InputsModel and '['.OutputsModel run like a "classical"...

v1.6.9.3 refactor: '['.InputsModel and '['.OutputsModel run like a "classical" call of the '[' if the index is a charcater
Refs #67
parent 4863f7a6
Pipeline #18976 canceled with stages
in 9 seconds
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.9.2
Version: 1.6.9.3
Date: 2021-01-08
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -2,7 +2,7 @@
### 1.6.9.2 Release Notes (2021-01-08)
### 1.6.9.3 Release Notes (2021-01-08)
#### New features
......
......@@ -109,7 +109,16 @@
if (!inherits(x, "InputsModel")) {
stop("'x' must be of class 'InputsModel'")
}
.ExtractInputsModel(x, i)
if (is.factor(i)) {
i <- as.character(i)
}
if (is.numeric(i)) {
res <- .ExtractInputsModel(x, i)
} else {
res <- lapply(i, function(name) x[[name, exact = TRUE]])
names(res) <- i
}
return(res)
}
......@@ -148,5 +157,14 @@
if (!inherits(x, "OutputsModel")) {
stop("'x' must be of class 'OutputsModel'")
}
.ExtractOutputsModel(x, i)
if (is.factor(i)) {
i <- as.character(i)
}
if (is.numeric(i)) {
res <- .ExtractOutputsModel(x, i)
} else {
res <- lapply(i, function(name) x[[name, exact = TRUE]])
names(res) <- i
}
return(res)
}
Markdown is supported
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