From 1521be06c4e7cd33f790c5e36b27c52c351498c0 Mon Sep 17 00:00:00 2001 From: Greg Faletto Date: Thu, 18 May 2023 21:44:52 -0700 Subject: [PATCH 1/2] Modify check_output to explicitly pass the errors object to is_valid_rij_list --- R/output-class.R | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/R/output-class.R b/R/output-class.R index b5c6972..7e80eb4 100644 --- a/R/output-class.R +++ b/R/output-class.R @@ -1,21 +1,21 @@ -is_valid_rij_list <- function(out, index) { +is_valid_rij_list <- function(out, index, errs) { if (length(out) < 1) { - errors <- c(errors, "out must be nonempty.") + errs <- c(errs, "out must be nonempty.") } else { str <- "incorrectly named elements of out. See documentation." # should be of format ri.j where i is in index and j starts at 1. pattern <- "^r([[:digit:]]+)[.]([[:digit:]]+)$" i <- as.numeric(gsub(pattern, "\\1", names(out))) j <- as.numeric(gsub(pattern, "\\2", names(out))) - if (any(is.na(i))) errors <- c(errors, str) + if (any(is.na(i))) errs <- c(errs, str) if (any(sort(unique(i)) != sort(index))) - errors <- c(errors, "index does not match elements in out list.") + errs <- c(errs, "index does not match elements in out list.") } if (!all(unlist(lapply(out, is.list)))) - errors <- c(errors, "out$ri.j should be a list.") + errs <- c(errs, "out$ri.j should be a list.") nams <- lapply(out, function(r) names(r)) if (!all(unlist(lapply(nams, function(nam) identical(nam, nams[[1]]))))) - errors <- c(errors, "all out$ri.j must have same elements.") + errs <- c(errs, "all out$ri.j must have same elements.") } check_output <- function(object) { @@ -30,7 +30,7 @@ check_output <- function(object) { errors <- c(errors, "index must be an integer-valued numeric.") if (length(object@method_label) != 1) errors <- c(errors, "method_label must be of length 1.") - errors <- c(errors, is_valid_rij_list(object@out, object@index)) + errors <- c(errors, is_valid_rij_list(object@out, object@index, errors)) if (length(errors) == 0) TRUE else errors } From d3ee541277af85e1f532e6fca1255e79623c144b Mon Sep 17 00:00:00 2001 From: jacobbien Date: Mon, 22 May 2023 12:32:50 -0700 Subject: [PATCH 2/2] Avoid passing errors since it's never used --- R/output-class.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/output-class.R b/R/output-class.R index 7e80eb4..c4959be 100644 --- a/R/output-class.R +++ b/R/output-class.R @@ -1,4 +1,5 @@ -is_valid_rij_list <- function(out, index, errs) { +is_valid_rij_list <- function(out, index) { + errs <- c() if (length(out) < 1) { errs <- c(errs, "out must be nonempty.") } else { @@ -30,7 +31,7 @@ check_output <- function(object) { errors <- c(errors, "index must be an integer-valued numeric.") if (length(object@method_label) != 1) errors <- c(errors, "method_label must be of length 1.") - errors <- c(errors, is_valid_rij_list(object@out, object@index, errors)) + errors <- c(errors, is_valid_rij_list(object@out, object@index)) if (length(errors) == 0) TRUE else errors }