You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by viirya <gi...@git.apache.org> on 2017/05/03 07:36:47 UTC

[GitHub] spark pull request #17459: [SPARK-20109][MLlib] Rewrote toBlockMatrix method...

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

    https://github.com/apache/spark/pull/17459#discussion_r114485962
  
    --- Diff: mllib/src/test/scala/org/apache/spark/mllib/linalg/distributed/IndexedRowMatrixSuite.scala ---
    @@ -87,19 +87,96 @@ 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) =>
    --- End diff --
    
    nit: the style looks weird.
    
    Maybe:
    
        assert(blockMat.blocks.map { case (_, matrix: Matrix) =>
          matrix.isInstanceOf[DenseMatrix]
        }.reduce(_ && _))


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

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