Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Commit 8ef0059

Browse files
wangmiao1981yanboliang
authored andcommitted
[MINOR][SPARKR] fix kstest example error and add unit test
## What changes were proposed in this pull request? While adding vignettes for kstest, I found some errors in the example: 1. There is a typo of kstest; 2. print.summary.KStest doesn't work with the example; Fix the example errors; Add a new unit test for print.summary.KStest; ## How was this patch tested? Manual test; Add new unit test; Author: [email protected] <[email protected]> Closes apache#16259 from wangmiao1981/ks. (cherry picked from commit f2ddabf) Signed-off-by: Yanbo Liang <[email protected]>
1 parent 019d1fa commit 8ef0059

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

R/pkg/R/mllib.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,14 +1595,14 @@ setMethod("write.ml", signature(object = "ALSModel", path = "character"),
15951595
#' \dontrun{
15961596
#' data <- data.frame(test = c(0.1, 0.15, 0.2, 0.3, 0.25))
15971597
#' df <- createDataFrame(data)
1598-
#' test <- spark.ktest(df, "test", "norm", c(0, 1))
1598+
#' test <- spark.kstest(df, "test", "norm", c(0, 1))
15991599
#'
16001600
#' # get a summary of the test result
16011601
#' testSummary <- summary(test)
16021602
#' testSummary
16031603
#'
16041604
#' # print out the summary in an organized way
1605-
#' print.summary.KSTest(test)
1605+
#' print.summary.KSTest(testSummary)
16061606
#' }
16071607
#' @note spark.kstest since 2.1.0
16081608
setMethod("spark.kstest", signature(data = "SparkDataFrame"),

R/pkg/inst/tests/testthat/test_mllib.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,12 @@ test_that("spark.kstest", {
986986
expect_equal(stats$p.value, rStats$p.value, tolerance = 1e-4)
987987
expect_equal(stats$statistic, unname(rStats$statistic), tolerance = 1e-4)
988988
expect_match(capture.output(stats)[1], "Kolmogorov-Smirnov test summary:")
989+
990+
# Test print.summary.KSTest
991+
printStats <- capture.output(print.summary.KSTest(stats))
992+
expect_match(printStats[1], "Kolmogorov-Smirnov test summary:")
993+
expect_match(printStats[5],
994+
"Low presumption against null hypothesis: Sample follows theoretical distribution. ")
989995
})
990996

991997
test_that("spark.randomForest", {

0 commit comments

Comments
 (0)