aboutsummaryrefslogtreecommitdiff
path: root/mllib/src/test
diff options
context:
space:
mode:
authorMechCoder <manojkumarsivaraj334@gmail.com>2015-03-20 17:13:18 -0400
committerXiangrui Meng <meng@databricks.com>2015-03-20 17:13:18 -0400
commit11e025956be3818c00effef0d650734f8feeb436 (patch)
treeb63913e36a5e40819a32696b13b180894eafbaba /mllib/src/test
parent49a01c7ea2c48feee7ab4551c4fa03fd1cdb1a32 (diff)
downloadspark-11e025956be3818c00effef0d650734f8feeb436.tar.gz
spark-11e025956be3818c00effef0d650734f8feeb436.tar.bz2
spark-11e025956be3818c00effef0d650734f8feeb436.zip
[SPARK-6309] [SQL] [MLlib] Implement MatrixUDT
Utilities to serialize and deserialize Matrices in MLlib Author: MechCoder <manojkumarsivaraj334@gmail.com> Closes #5048 from MechCoder/spark-6309 and squashes the following commits: 05dc6f2 [MechCoder] Hashcode and organize imports 16d5d47 [MechCoder] Test some more 6e67020 [MechCoder] TST: Test using Array conversion instead of equals 7fa7a2c [MechCoder] [SPARK-6309] [SQL] [MLlib] Implement MatrixUDT
Diffstat (limited to 'mllib/src/test')
-rw-r--r--mllib/src/test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/mllib/src/test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala b/mllib/src/test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala
index c098b5458f..96f677db3f 100644
--- a/mllib/src/test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala
+++ b/mllib/src/test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala
@@ -424,4 +424,17 @@ class MatricesSuite extends FunSuite {
assert(mat.rowIndices.toSeq === Seq(3, 0, 2, 1))
assert(mat.values.toSeq === Seq(1.0, 2.0, 3.0, 4.0))
}
+
+ test("MatrixUDT") {
+ val dm1 = new DenseMatrix(2, 2, Array(0.9, 1.2, 2.3, 9.8))
+ val dm2 = new DenseMatrix(3, 2, Array(0.0, 1.21, 2.3, 9.8, 9.0, 0.0))
+ val dm3 = new DenseMatrix(0, 0, Array())
+ val sm1 = dm1.toSparse
+ val sm2 = dm2.toSparse
+ val sm3 = dm3.toSparse
+ val mUDT = new MatrixUDT()
+ Seq(dm1, dm2, dm3, sm1, sm2, sm3).foreach {
+ mat => assert(mat.toArray === mUDT.deserialize(mUDT.serialize(mat)).toArray)
+ }
+ }
}