@@ -119,23 +119,23 @@ class IndexedRowMatrixSuite extends SparkFunSuite with MLlibTestSparkContext {
119119
120120 test(" toBlockMatrix sparse backing" ) {
121121 val sparseData = Seq (
122- (7L , Vectors .sparse(6 , Seq ((0 , 4.0 ))))
122+ (15L , Vectors .sparse(12 , Seq ((0 , 4.0 ))))
123123 ).map(x => IndexedRow (x._1, x._2))
124124
125125 // Gonna make m and n larger here so the matrices can easily be completely sparse:
126- val m = 8
127- val n = 6
126+ val m = 16
127+ val n = 12
128128
129129 val idxRowMatSparse = new IndexedRowMatrix (sc.parallelize(sparseData))
130130
131131 // Tests when n % colsPerBlock != 0
132- val blockMat = idxRowMatSparse.toBlockMatrix(4 , 4 )
132+ val blockMat = idxRowMatSparse.toBlockMatrix(8 , 8 )
133133 assert(blockMat.numRows() === m)
134134 assert(blockMat.numCols() === n)
135135 assert(blockMat.toBreeze() === idxRowMatSparse.toBreeze())
136136
137137 // Tests when m % rowsPerBlock != 0
138- val blockMat2 = idxRowMatSparse.toBlockMatrix(3 , 3 )
138+ val blockMat2 = idxRowMatSparse.toBlockMatrix(6 , 6 )
139139 assert(blockMat2.numRows() === m)
140140 assert(blockMat2.numCols() === n)
141141 assert(blockMat2.toBreeze() === idxRowMatSparse.toBreeze())
@@ -149,38 +149,34 @@ class IndexedRowMatrixSuite extends SparkFunSuite with MLlibTestSparkContext {
149149 }
150150
151151 test(" toBlockMatrix mixed backing" ) {
152+ val m = 24
153+ val n = 18
154+
152155 val mixedData = Seq (
153- (0L , Vectors .dense(1 , 2 , 3 )),
154- (3L , Vectors .sparse(3 , Seq ((0 , 4.0 )))))
156+ (0L , Vectors .dense((0 to 17 ).map(_.toDouble).toArray)),
157+ (1L , Vectors .dense((0 to 17 ).map(_.toDouble).toArray)),
158+ (23L , Vectors .sparse(18 , Seq ((0 , 4.0 )))))
155159 .map(x => IndexedRow (x._1, x._2))
156160
157161 val idxRowMatMixed = new IndexedRowMatrix (
158162 sc.parallelize(mixedData))
159163
160164 // Tests when n % colsPerBlock != 0
161- val blockMat = idxRowMatMixed.toBlockMatrix(2 , 2 )
165+ val blockMat = idxRowMatMixed.toBlockMatrix(12 , 12 )
162166 assert(blockMat.numRows() === m)
163167 assert(blockMat.numCols() === n)
164168 assert(blockMat.toBreeze() === idxRowMatMixed.toBreeze())
165169
166170 // Tests when m % rowsPerBlock != 0
167- val blockMat2 = idxRowMatMixed.toBlockMatrix(3 , 1 )
171+ val blockMat2 = idxRowMatMixed.toBlockMatrix(18 , 6 )
168172 assert(blockMat2.numRows() === m)
169173 assert(blockMat2.numCols() === n)
170174 assert(blockMat2.toBreeze() === idxRowMatMixed.toBreeze())
171175
172176 val blocks = blockMat.blocks.collect()
173177
174- /* Diagram of mixed data blockmat. Lines indicate blocking.
175- 1 2 | 3
176- 0 0 | 0
177- -------
178- 0 0 | 0
179- 4 0 | 0
180- */
181-
182- blocks.forall { case ((row, col), matrix) =>
183- if (row == 0 ) matrix.isInstanceOf [DenseMatrix ] else matrix.isInstanceOf [SparseMatrix ]}
178+ assert(blocks.forall { case ((row, col), matrix) =>
179+ if (row == 0 ) matrix.isInstanceOf [DenseMatrix ] else matrix.isInstanceOf [SparseMatrix ]})
184180 }
185181
186182 test(" multiply a local matrix" ) {
0 commit comments