From 4a83395681e0bca356363a6cfb25c952f235560d Mon Sep 17 00:00:00 2001 From: hyukjinkwon Date: Tue, 27 Sep 2016 21:19:59 -0700 Subject: [SPARK-17499][SPARKR][FOLLOWUP] Check null first for layers in spark.mlp to avoid warnings in test results ## What changes were proposed in this pull request? Some tests in `test_mllib.r` are as below: ```r expect_error(spark.mlp(df, layers = NULL), "layers must be a integer vector with length > 1.") expect_error(spark.mlp(df, layers = c()), "layers must be a integer vector with length > 1.") ``` The problem is, `is.na` is internally called via `na.omit` in `spark.mlp` which causes warnings as below: ``` Warnings ----------------------------------------------------------------------- 1. spark.mlp (test_mllib.R#400) - is.na() applied to non-(list or vector) of type 'NULL' 2. spark.mlp (test_mllib.R#401) - is.na() applied to non-(list or vector) of type 'NULL' ``` ## How was this patch tested? Manually tested. Also, Jenkins tests and AppVeyor. Author: hyukjinkwon Closes #15232 from HyukjinKwon/remove-warnnings. --- R/pkg/R/mllib.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/pkg/R/mllib.R b/R/pkg/R/mllib.R index 971c16658f..b901307f8f 100644 --- a/R/pkg/R/mllib.R +++ b/R/pkg/R/mllib.R @@ -696,6 +696,9 @@ setMethod("predict", signature(object = "KMeansModel"), setMethod("spark.mlp", signature(data = "SparkDataFrame"), function(data, layers, blockSize = 128, solver = "l-bfgs", maxIter = 100, tol = 1E-6, stepSize = 0.03, seed = NULL) { + if (is.null(layers)) { + stop ("layers must be a integer vector with length > 1.") + } layers <- as.integer(na.omit(layers)) if (length(layers) <= 1) { stop ("layers must be a integer vector with length > 1.") -- cgit v1.2.3