diff options
author | Funes <tianshaocun@gmail.com> | 2014-05-08 17:54:10 -0700 |
---|---|---|
committer | Patrick Wendell <pwendell@gmail.com> | 2014-05-08 17:54:10 -0700 |
commit | 191279ce4edb940821d11a6b25cd33c8ad0af054 (patch) | |
tree | 58d495386b67237eacb282fb58f9668f6496b495 /mllib/src/test | |
parent | 910a13b3c52a6309068b4997da6df6b7d6058a1b (diff) | |
download | spark-191279ce4edb940821d11a6b25cd33c8ad0af054.tar.gz spark-191279ce4edb940821d11a6b25cd33c8ad0af054.tar.bz2 spark-191279ce4edb940821d11a6b25cd33c8ad0af054.zip |
Bug fix of sparse vector conversion
Fixed a small bug caused by the inconsistency of index/data array size and vector length.
Author: Funes <tianshaocun@gmail.com>
Author: funes <tianshaocun@gmail.com>
Closes #661 from funes/bugfix and squashes the following commits:
edb2b9d [funes] remove unused import
75dced3 [Funes] update test case
d129a66 [Funes] Add test for sparse breeze by vector builder
64e7198 [Funes] Copy data only when necessary
b85806c [Funes] Bug fix of sparse vector conversion
Diffstat (limited to 'mllib/src/test')
-rw-r--r-- | mllib/src/test/scala/org/apache/spark/mllib/linalg/BreezeVectorConversionSuite.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mllib/src/test/scala/org/apache/spark/mllib/linalg/BreezeVectorConversionSuite.scala b/mllib/src/test/scala/org/apache/spark/mllib/linalg/BreezeVectorConversionSuite.scala index aacaa30084..8abdac7290 100644 --- a/mllib/src/test/scala/org/apache/spark/mllib/linalg/BreezeVectorConversionSuite.scala +++ b/mllib/src/test/scala/org/apache/spark/mllib/linalg/BreezeVectorConversionSuite.scala @@ -55,4 +55,13 @@ class BreezeVectorConversionSuite extends FunSuite { assert(vec.indices.eq(indices), "should not copy data") assert(vec.values.eq(values), "should not copy data") } + + test("sparse breeze with partially-used arrays to vector") { + val activeSize = 3 + val breeze = new BSV[Double](indices, values, activeSize, n) + val vec = Vectors.fromBreeze(breeze).asInstanceOf[SparseVector] + assert(vec.size === n) + assert(vec.indices === indices.slice(0, activeSize)) + assert(vec.values === values.slice(0, activeSize)) + } } |