aboutsummaryrefslogtreecommitdiff
path: root/mllib-local/src/test
diff options
context:
space:
mode:
authorDB Tsai <dbt@netflix.com>2016-05-27 14:02:39 -0700
committerJoseph K. Bradley <joseph@databricks.com>2016-05-27 14:02:39 -0700
commit21b2605dc4900894ea7a911e039781ecc2a18c14 (patch)
tree033e2083e4db2951acb9a76d14a0b530ad412f69 /mllib-local/src/test
parent130b8d07b8eb08f2ad522081a95032b90247094d (diff)
downloadspark-21b2605dc4900894ea7a911e039781ecc2a18c14.tar.gz
spark-21b2605dc4900894ea7a911e039781ecc2a18c14.tar.bz2
spark-21b2605dc4900894ea7a911e039781ecc2a18c14.zip
[SPARK-15413][ML][MLLIB] Change `toBreeze` to `asBreeze` in Vector and Matrix
## What changes were proposed in this pull request? We're using `asML` to convert the mllib vector/matrix to ml vector/matrix now. Using `as` is more correct given that this conversion actually shares the same underline data structure. As a result, in this PR, `toBreeze` will be changed to `asBreeze`. This is a private API, as a result, it will not affect any user's application. ## How was this patch tested? unit tests Author: DB Tsai <dbt@netflix.com> Closes #13198 from dbtsai/minor.
Diffstat (limited to 'mllib-local/src/test')
-rw-r--r--mllib-local/src/test/scala/org/apache/spark/ml/linalg/BreezeMatrixConversionSuite.scala4
-rw-r--r--mllib-local/src/test/scala/org/apache/spark/ml/linalg/BreezeVectorConversionSuite.scala4
-rw-r--r--mllib-local/src/test/scala/org/apache/spark/ml/linalg/MatricesSuite.scala14
-rw-r--r--mllib-local/src/test/scala/org/apache/spark/ml/linalg/VectorsSuite.scala2
4 files changed, 12 insertions, 12 deletions
diff --git a/mllib-local/src/test/scala/org/apache/spark/ml/linalg/BreezeMatrixConversionSuite.scala b/mllib-local/src/test/scala/org/apache/spark/ml/linalg/BreezeMatrixConversionSuite.scala
index 70a21e41bf..f07ed20cf0 100644
--- a/mllib-local/src/test/scala/org/apache/spark/ml/linalg/BreezeMatrixConversionSuite.scala
+++ b/mllib-local/src/test/scala/org/apache/spark/ml/linalg/BreezeMatrixConversionSuite.scala
@@ -24,7 +24,7 @@ import org.apache.spark.ml.SparkMLFunSuite
class BreezeMatrixConversionSuite extends SparkMLFunSuite {
test("dense matrix to breeze") {
val mat = Matrices.dense(3, 2, Array(0.0, 1.0, 2.0, 3.0, 4.0, 5.0))
- val breeze = mat.toBreeze.asInstanceOf[BDM[Double]]
+ val breeze = mat.asBreeze.asInstanceOf[BDM[Double]]
assert(breeze.rows === mat.numRows)
assert(breeze.cols === mat.numCols)
assert(breeze.data.eq(mat.asInstanceOf[DenseMatrix].values), "should not copy data")
@@ -48,7 +48,7 @@ class BreezeMatrixConversionSuite extends SparkMLFunSuite {
val colPtrs = Array(0, 2, 4)
val rowIndices = Array(1, 2, 1, 2)
val mat = Matrices.sparse(3, 2, colPtrs, rowIndices, values)
- val breeze = mat.toBreeze.asInstanceOf[BSM[Double]]
+ val breeze = mat.asBreeze.asInstanceOf[BSM[Double]]
assert(breeze.rows === mat.numRows)
assert(breeze.cols === mat.numCols)
assert(breeze.data.eq(mat.asInstanceOf[SparseMatrix].values), "should not copy data")
diff --git a/mllib-local/src/test/scala/org/apache/spark/ml/linalg/BreezeVectorConversionSuite.scala b/mllib-local/src/test/scala/org/apache/spark/ml/linalg/BreezeVectorConversionSuite.scala
index 00c9ee79eb..4c9740b6bc 100644
--- a/mllib-local/src/test/scala/org/apache/spark/ml/linalg/BreezeVectorConversionSuite.scala
+++ b/mllib-local/src/test/scala/org/apache/spark/ml/linalg/BreezeVectorConversionSuite.scala
@@ -33,12 +33,12 @@ class BreezeVectorConversionSuite extends SparkMLFunSuite {
test("dense to breeze") {
val vec = Vectors.dense(arr)
- assert(vec.toBreeze === new BDV[Double](arr))
+ assert(vec.asBreeze === new BDV[Double](arr))
}
test("sparse to breeze") {
val vec = Vectors.sparse(n, indices, values)
- assert(vec.toBreeze === new BSV[Double](indices, values, n))
+ assert(vec.asBreeze === new BSV[Double](indices, values, n))
}
test("dense breeze to vector") {
diff --git a/mllib-local/src/test/scala/org/apache/spark/ml/linalg/MatricesSuite.scala b/mllib-local/src/test/scala/org/apache/spark/ml/linalg/MatricesSuite.scala
index 5c69c5ed7b..2796fcf2cb 100644
--- a/mllib-local/src/test/scala/org/apache/spark/ml/linalg/MatricesSuite.scala
+++ b/mllib-local/src/test/scala/org/apache/spark/ml/linalg/MatricesSuite.scala
@@ -61,7 +61,7 @@ class MatricesSuite extends SparkMLFunSuite {
(1, 2, 2.0), (2, 2, 2.0), (1, 2, 2.0), (0, 0, 0.0))
val mat2 = SparseMatrix.fromCOO(m, n, entries)
- assert(mat.toBreeze === mat2.toBreeze)
+ assert(mat.asBreeze === mat2.asBreeze)
assert(mat2.values.length == 4)
}
@@ -174,8 +174,8 @@ class MatricesSuite extends SparkMLFunSuite {
val spMat2 = deMat1.toSparse
val deMat2 = spMat1.toDense
- assert(spMat1.toBreeze === spMat2.toBreeze)
- assert(deMat1.toBreeze === deMat2.toBreeze)
+ assert(spMat1.asBreeze === spMat2.asBreeze)
+ assert(deMat1.asBreeze === deMat2.asBreeze)
}
test("map, update") {
@@ -209,8 +209,8 @@ class MatricesSuite extends SparkMLFunSuite {
val sATexpected =
new SparseMatrix(3, 4, Array(0, 1, 2, 3, 4), Array(1, 0, 1, 2), Array(2.0, 1.0, 1.0, 3.0))
- assert(dAT.toBreeze === dATexpected.toBreeze)
- assert(sAT.toBreeze === sATexpected.toBreeze)
+ assert(dAT.asBreeze === dATexpected.asBreeze)
+ assert(sAT.asBreeze === sATexpected.asBreeze)
assert(dA(1, 0) === dAT(0, 1))
assert(dA(2, 1) === dAT(1, 2))
assert(sA(1, 0) === sAT(0, 1))
@@ -219,8 +219,8 @@ class MatricesSuite extends SparkMLFunSuite {
assert(!dA.toArray.eq(dAT.toArray), "has to have a new array")
assert(dA.values.eq(dAT.transpose.asInstanceOf[DenseMatrix].values), "should not copy array")
- assert(dAT.toSparse.toBreeze === sATexpected.toBreeze)
- assert(sAT.toDense.toBreeze === dATexpected.toBreeze)
+ assert(dAT.toSparse.asBreeze === sATexpected.asBreeze)
+ assert(sAT.toDense.asBreeze === dATexpected.asBreeze)
}
test("foreachActive") {
diff --git a/mllib-local/src/test/scala/org/apache/spark/ml/linalg/VectorsSuite.scala b/mllib-local/src/test/scala/org/apache/spark/ml/linalg/VectorsSuite.scala
index 887814b5e7..614be460a4 100644
--- a/mllib-local/src/test/scala/org/apache/spark/ml/linalg/VectorsSuite.scala
+++ b/mllib-local/src/test/scala/org/apache/spark/ml/linalg/VectorsSuite.scala
@@ -230,7 +230,7 @@ class VectorsSuite extends SparkMLFunSuite {
val denseVector1 = Vectors.dense(sparseVector1.toArray)
val denseVector2 = Vectors.dense(sparseVector2.toArray)
- val squaredDist = breezeSquaredDistance(sparseVector1.toBreeze, sparseVector2.toBreeze)
+ val squaredDist = breezeSquaredDistance(sparseVector1.asBreeze, sparseVector2.asBreeze)
// SparseVector vs. SparseVector
assert(Vectors.sqdist(sparseVector1, sparseVector2) ~== squaredDist relTol 1E-8)