aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyukjinkwon <gurwls223@gmail.com>2016-09-27 21:19:59 -0700
committerFelix Cheung <felixcheung@apache.org>2016-09-27 21:19:59 -0700
commit4a83395681e0bca356363a6cfb25c952f235560d (patch)
treea71860c67b72da3a2e6cfe356a5bf884343bba83
parentb03b4adf6d8f4c6d92575c0947540cb474bf7de1 (diff)
downloadspark-4a83395681e0bca356363a6cfb25c952f235560d.tar.gz
spark-4a83395681e0bca356363a6cfb25c952f235560d.tar.bz2
spark-4a83395681e0bca356363a6cfb25c952f235560d.zip
[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 <gurwls223@gmail.com> Closes #15232 from HyukjinKwon/remove-warnnings.
-rw-r--r--R/pkg/R/mllib.R3
1 files changed, 3 insertions, 0 deletions
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.")