From 4df4236f22489a6eabc51deeb0c22dce8c7748a4 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Fri, 30 Mar 2018 22:03:53 +0100 Subject: Return invisibly on error --- R/gensvm.R | 4 ++-- R/gensvm.grid.R | 6 +++--- R/plot.gensvm.R | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/gensvm.R b/R/gensvm.R index 425bf9b..acc39ef 100644 --- a/R/gensvm.R +++ b/R/gensvm.R @@ -138,10 +138,10 @@ gensvm <- function(X, y, p=1.0, lambda=1e-8, kappa=0.0, epsilon=1e-6, if (gamma == 'auto') gamma <- 1.0/n.features - if (!gensvm.validate.params(p=p, kappa=kappa, lambda=lambda, + if (!gensvm.validate.params(p=p, kappa=kappa, lambda=lambda, epsilon=epsilon, gamma=gamma, weights=weights, kernel=kernel)) - invisible(NULL) + return(invisible(NULL)) # Convert weights to index weight.idx <- which(c("unit", "group") == weights) diff --git a/R/gensvm.grid.R b/R/gensvm.grid.R index 8f875a3..c541ea0 100644 --- a/R/gensvm.grid.R +++ b/R/gensvm.grid.R @@ -157,8 +157,8 @@ gensvm.grid <- function(X, y, param.grid='tiny', refit=TRUE, scoring=NULL, cv=3, n.classes <- length(unique(y)) if (n.objects != length(y)) { - cat("Error: X and y are not the same length.\n") - invisible(NULL) + cat("Error: x and y are not the same length.\n") + return(invisible(NULL)) } if (is.character(param.grid)) { @@ -173,7 +173,7 @@ gensvm.grid <- function(X, y, param.grid='tiny', refit=TRUE, scoring=NULL, cv=3, # Validate the range of the values for the gridsearch if (!gensvm.validate.param.grid(param.grid)) - invisible(NULL) + return(invisible(NULL)) # Sort the parameter grid for efficient warm starts param.grid <- gensvm.sort.param.grid(param.grid) diff --git a/R/plot.gensvm.R b/R/plot.gensvm.R index e79881f..ac40ccf 100644 --- a/R/plot.gensvm.R +++ b/R/plot.gensvm.R @@ -65,7 +65,7 @@ plot.gensvm <- function(fit, x, y.true=NULL, with.margins=TRUE, { if (!(fit$n.classes %in% c(2,3))) { cat("Error: Can only plot with 2 or 3 classes\n") - invisible(NULL) + return(invisible(NULL)) } # Sanity check -- cgit v1.2.3