spark git commit: [SPARK-23091][ML] Incorrect unit test for approxQuantile

2018-01-19 Thread lixiao
Repository: spark
Updated Branches:
  refs/heads/master 793841c6b -> 396cdfbea


[SPARK-23091][ML] Incorrect unit test for approxQuantile

## What changes were proposed in this pull request?

Narrow bound on approx quantile test to epsilon from 2*epsilon to match paper

## How was this patch tested?

Existing tests.

Author: Sean Owen 

Closes #20324 from srowen/SPARK-23091.


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

Branch: refs/heads/master
Commit: 396cdfbea45232bacbc03bfaf8be4ea85d47d3fd
Parents: 793841c
Author: Sean Owen 
Authored: Fri Jan 19 22:46:34 2018 -0800
Committer: gatorsmile 
Committed: Fri Jan 19 22:46:34 2018 -0800

--
 .../apache/spark/sql/DataFrameStatSuite.scala   | 24 ++--
 1 file changed, 12 insertions(+), 12 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/spark/blob/396cdfbe/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
--
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala 
b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
index 5169d2b..8eae353 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
@@ -154,24 +154,24 @@ class DataFrameStatSuite extends QueryTest with 
SharedSQLContext {
   val Array(d1, d2) = df.stat.approxQuantile("doubles", Array(q1, q2), 
epsilon)
   val Array(s1, s2) = df.stat.approxQuantile("singles", Array(q1, q2), 
epsilon)
 
-  val error_single = 2 * 1000 * epsilon
-  val error_double = 2 * 2000 * epsilon
+  val errorSingle = 1000 * epsilon
+  val errorDouble = 2.0 * errorSingle
 
-  assert(math.abs(single1 - q1 * n) < error_single)
-  assert(math.abs(double2 - 2 * q2 * n) < error_double)
-  assert(math.abs(s1 - q1 * n) < error_single)
-  assert(math.abs(s2 - q2 * n) < error_single)
-  assert(math.abs(d1 - 2 * q1 * n) < error_double)
-  assert(math.abs(d2 - 2 * q2 * n) < error_double)
+  assert(math.abs(single1 - q1 * n) <= errorSingle)
+  assert(math.abs(double2 - 2 * q2 * n) <= errorDouble)
+  assert(math.abs(s1 - q1 * n) <= errorSingle)
+  assert(math.abs(s2 - q2 * n) <= errorSingle)
+  assert(math.abs(d1 - 2 * q1 * n) <= errorDouble)
+  assert(math.abs(d2 - 2 * q2 * n) <= errorDouble)
 
   // Multiple columns
   val Array(Array(ms1, ms2), Array(md1, md2)) =
 df.stat.approxQuantile(Array("singles", "doubles"), Array(q1, q2), 
epsilon)
 
-  assert(math.abs(ms1 - q1 * n) < error_single)
-  assert(math.abs(ms2 - q2 * n) < error_single)
-  assert(math.abs(md1 - 2 * q1 * n) < error_double)
-  assert(math.abs(md2 - 2 * q2 * n) < error_double)
+  assert(math.abs(ms1 - q1 * n) <= errorSingle)
+  assert(math.abs(ms2 - q2 * n) <= errorSingle)
+  assert(math.abs(md1 - 2 * q1 * n) <= errorDouble)
+  assert(math.abs(md2 - 2 * q2 * n) <= errorDouble)
 }
 
 // quantile should be in the range [0.0, 1.0]


-
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org



spark git commit: [SPARK-23091][ML] Incorrect unit test for approxQuantile

2018-01-19 Thread lixiao
Repository: spark
Updated Branches:
  refs/heads/branch-2.3 c647f918b -> 0cde5212a


[SPARK-23091][ML] Incorrect unit test for approxQuantile

## What changes were proposed in this pull request?

Narrow bound on approx quantile test to epsilon from 2*epsilon to match paper

## How was this patch tested?

Existing tests.

Author: Sean Owen 

Closes #20324 from srowen/SPARK-23091.

(cherry picked from commit 396cdfbea45232bacbc03bfaf8be4ea85d47d3fd)
Signed-off-by: gatorsmile 


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

Branch: refs/heads/branch-2.3
Commit: 0cde5212a80b5572bfe53b06ed557e6c2ec8c903
Parents: c647f91
Author: Sean Owen 
Authored: Fri Jan 19 22:46:34 2018 -0800
Committer: gatorsmile 
Committed: Fri Jan 19 22:46:47 2018 -0800

--
 .../apache/spark/sql/DataFrameStatSuite.scala   | 24 ++--
 1 file changed, 12 insertions(+), 12 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/spark/blob/0cde5212/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
--
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala 
b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
index 5169d2b..8eae353 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
@@ -154,24 +154,24 @@ class DataFrameStatSuite extends QueryTest with 
SharedSQLContext {
   val Array(d1, d2) = df.stat.approxQuantile("doubles", Array(q1, q2), 
epsilon)
   val Array(s1, s2) = df.stat.approxQuantile("singles", Array(q1, q2), 
epsilon)
 
-  val error_single = 2 * 1000 * epsilon
-  val error_double = 2 * 2000 * epsilon
+  val errorSingle = 1000 * epsilon
+  val errorDouble = 2.0 * errorSingle
 
-  assert(math.abs(single1 - q1 * n) < error_single)
-  assert(math.abs(double2 - 2 * q2 * n) < error_double)
-  assert(math.abs(s1 - q1 * n) < error_single)
-  assert(math.abs(s2 - q2 * n) < error_single)
-  assert(math.abs(d1 - 2 * q1 * n) < error_double)
-  assert(math.abs(d2 - 2 * q2 * n) < error_double)
+  assert(math.abs(single1 - q1 * n) <= errorSingle)
+  assert(math.abs(double2 - 2 * q2 * n) <= errorDouble)
+  assert(math.abs(s1 - q1 * n) <= errorSingle)
+  assert(math.abs(s2 - q2 * n) <= errorSingle)
+  assert(math.abs(d1 - 2 * q1 * n) <= errorDouble)
+  assert(math.abs(d2 - 2 * q2 * n) <= errorDouble)
 
   // Multiple columns
   val Array(Array(ms1, ms2), Array(md1, md2)) =
 df.stat.approxQuantile(Array("singles", "doubles"), Array(q1, q2), 
epsilon)
 
-  assert(math.abs(ms1 - q1 * n) < error_single)
-  assert(math.abs(ms2 - q2 * n) < error_single)
-  assert(math.abs(md1 - 2 * q1 * n) < error_double)
-  assert(math.abs(md2 - 2 * q2 * n) < error_double)
+  assert(math.abs(ms1 - q1 * n) <= errorSingle)
+  assert(math.abs(ms2 - q2 * n) <= errorSingle)
+  assert(math.abs(md1 - 2 * q1 * n) <= errorDouble)
+  assert(math.abs(md2 - 2 * q2 * n) <= errorDouble)
 }
 
 // quantile should be in the range [0.0, 1.0]


-
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org