From 05cf434bab88f6272a30237a80a088ec51e40abd Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.fr>
Date: Fri, 8 Jan 2021 10:21:19 +0100
Subject: [PATCH] v1.6.9.3 refactor: '['.InputsModel and '['.OutputsModel run
 like a "classical" call of the '[' if the index is a charcater Refs #67

---
 DESCRIPTION |  2 +-
 NEWS.md     |  2 +-
 R/Utils.R   | 22 ++++++++++++++++++++--
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 4483efe4..58626d6f 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.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")),
diff --git a/NEWS.md b/NEWS.md
index 3f943f81..f8114bdf 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,7 +2,7 @@
 
 
 
-### 1.6.9.2 Release Notes (2021-01-08)
+### 1.6.9.3 Release Notes (2021-01-08)
 
 #### New features
 
diff --git a/R/Utils.R b/R/Utils.R
index b30a9e08..adf2d570 100644
--- a/R/Utils.R
+++ b/R/Utils.R
@@ -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)
 }
-- 
GitLab