Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/1713#discussion_r15685067
--- Diff:
mllib/src/test/scala/org/apache/spark/mllib/api/python/PythonMLLibAPISuite.scala
---
@@ -59,10 +59,25 @@ class PythonMLLibAPISuite extends FunSuite {
}
test("double serialization") {
- for (x <- List(123.0, -10.0, 0.0, Double.MaxValue, Double.MinValue)) {
+ for (x <- List(123.0, -10.0, 0.0, Double.MaxValue, Double.MinValue,
Double.NaN)) {
val bytes = py.serializeDouble(x)
val deser = py.deserializeDouble(bytes)
- assert(x === deser)
+ // We use `equals` here for comparison because we cannot use `==`
for NaN
+ assert(x.equals(deser))
}
}
+
+ test("matrix to 2D array") {
+ val values = Array[Double](0, 1.2, 3, 4.56, 7, 8)
+ val matrix = Matrices.dense(2, 3, values)
+ val twoDarray = py.to2dArray(matrix)
+ val expected = Array(Array[Double](0, 1.2, 3), Array[Double](4.56, 7,
8))
--- End diff --
The expected value should be `(0, 3, 7), (1.2, 4.56, 8)`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---