Repository: spark
Updated Branches:
  refs/heads/master b03b4adf6 -> 4a8339568


[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 <[email protected]>

Closes #15232 from HyukjinKwon/remove-warnnings.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/4a833956
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/4a833956
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/4a833956

Branch: refs/heads/master
Commit: 4a83395681e0bca356363a6cfb25c952f235560d
Parents: b03b4ad
Author: hyukjinkwon <[email protected]>
Authored: Tue Sep 27 21:19:59 2016 -0700
Committer: Felix Cheung <[email protected]>
Committed: Tue Sep 27 21:19:59 2016 -0700

----------------------------------------------------------------------
 R/pkg/R/mllib.R | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/4a833956/R/pkg/R/mllib.R
----------------------------------------------------------------------
diff --git a/R/pkg/R/mllib.R b/R/pkg/R/mllib.R
index 971c166..b901307 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.")


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to