From b3213bd6957d30431cdb52cbbabf010d46a1398b Mon Sep 17 00:00:00 2001 From: aho Date: Tue, 19 Nov 2019 11:15:41 +0100 Subject: [PATCH] Add name consistent check in AddStep when use_attributes is used --- R/AddStep.R | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/R/AddStep.R b/R/AddStep.R index c34e1b0..955ed84 100644 --- a/R/AddStep.R +++ b/R/AddStep.R @@ -9,7 +9,7 @@ AddStep <- function(inputs, step_fun, ...) { inputs <- list(inputs) names(inputs) <- 'input1' } - if (is.list(inputs)) { + else if (is.list(inputs)) { if (any(!sapply(inputs, function(x) any(c('startR_cube', 'startR_workflow') %in% class(x))))) { @@ -22,6 +22,15 @@ AddStep <- function(inputs, step_fun, ...) { } # Consistency checks + if (!is.null(attr(step_fun, "UseAttributes"))) { + if (!all(names(inputs) == names(attr(step_fun, "UseAttributes")))) { + names(inputs) <- names(attr(step_fun, "UseAttributes")) + .warning(paste("The name of inputs is not assigned or differs from", + "name of use_attributes list in Step(). Force inputs", + "name to be consistent with use_attributes list")) + } + } + if (length(inputs) != length(attr(step_fun, 'TargetDims'))) { stop("The number of provided 'inputs' (", length(inputs), ") does not ", "match the number of expected inputs by the provided 'step_fun' (", -- GitLab