Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test for single seed
  • Loading branch information
sameeragarwal committed Jan 7, 2016
commit be9630fde2b1e427b5bb0e1a0c51c04cddc862f8
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,21 @@ class DataFrameStatSuite extends QueryTest with SharedSQLContext {
// rows in each partition.
val data =
sparkContext.parallelize(1 to n, 2).mapPartitions(scala.util.Random.shuffle(_)).toDF("id")
for (seed <- 1 to 5) {
val splits = data.randomSplit(Array[Double](1, 2, 3), seed)
assert(splits.length == 3, "wrong number of splits")
val splits = data.randomSplit(Array[Double](1, 2, 3), seed = 1)
assert(splits.length == 3, "wrong number of splits")

assert(splits.reduce((a, b) => a.unionAll(b)).sort("id").collect().toList ==
data.sort($"id").collect().toList, "incomplete or wrong split")

for (id <- splits.indices) {
assert(splits(id).intersect(splits((id + 1) % splits.length)).collect().isEmpty,
s"split $id overlaps with split ${(id + 1) % splits.length}")
}
assert(splits.reduce((a, b) => a.unionAll(b)).sort("id").collect().toList ==
data.sort($"id").collect().toList, "incomplete or wrong split")

val s = splits.map(_.count())
assert(math.abs(s(0) - 100) < 50) // std = 9.13
assert(math.abs(s(1) - 200) < 50) // std = 11.55
assert(math.abs(s(2) - 300) < 50) // std = 12.25
for (id <- splits.indices) {
assert(splits(id).intersect(splits((id + 1) % splits.length)).collect().isEmpty,
s"split $id overlaps with split ${(id + 1) % splits.length}")
}

val s = splits.map(_.count())
assert(math.abs(s(0) - 100) < 50) // std = 9.13
assert(math.abs(s(1) - 200) < 50) // std = 11.55
assert(math.abs(s(2) - 300) < 50) // std = 12.25
}

test("pearson correlation") {
Expand Down