Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17459#discussion_r111305748
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/mllib/linalg/distributed/IndexedRowMatrixSuite.scala
 ---
    @@ -87,19 +87,92 @@ class IndexedRowMatrixSuite extends SparkFunSuite with 
MLlibTestSparkContext {
         assert(coordMat.toBreeze() === idxRowMat.toBreeze())
       }
     
    -  test("toBlockMatrix") {
    -    val idxRowMat = new IndexedRowMatrix(indexedRows)
    -    val blockMat = idxRowMat.toBlockMatrix(2, 2)
    +  test("toBlockMatrix dense backing") {
    +    val idxRowMatDense = new IndexedRowMatrix(indexedRows)
    +
    +    // Tests when n % colsPerBlock != 0
    +    val blockMat = idxRowMatDense.toBlockMatrix(2, 2)
         assert(blockMat.numRows() === m)
         assert(blockMat.numCols() === n)
    -    assert(blockMat.toBreeze() === idxRowMat.toBreeze())
    +    assert(blockMat.toBreeze() === idxRowMatDense.toBreeze())
    +
    +    // Tests when m % rowsPerBlock != 0
    +    val blockMat2 = idxRowMatDense.toBlockMatrix(3, 1)
    +    assert(blockMat2.numRows() === m)
    +    assert(blockMat2.numCols() === n)
    +    assert(blockMat2.toBreeze() === idxRowMatDense.toBreeze())
     
         intercept[IllegalArgumentException] {
    -      idxRowMat.toBlockMatrix(-1, 2)
    +      idxRowMatDense.toBlockMatrix(-1, 2)
         }
         intercept[IllegalArgumentException] {
    -      idxRowMat.toBlockMatrix(2, 0)
    +      idxRowMatDense.toBlockMatrix(2, 0)
         }
    +
    +    assert(blockMat.blocks.map { case (_, matrix: Matrix) =>
    +      matrix.isInstanceOf[DenseMatrix]}.reduce(_ && _))
    +    assert(blockMat2.blocks.map { case (_, matrix: Matrix) =>
    +      matrix.isInstanceOf[DenseMatrix]}.reduce(_ && _))
    +  }
    +
    +  test("toBlockMatrix sparse backing") {
    +    val sparseData = Seq(
    +      (2L, Vectors.sparse(3, Seq((0, 4.0))))
    --- End diff --
    
    Then the following `Tests when m % rowsPerBlock != 0` is not true anymore.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to