Repository: spark Updated Branches: refs/heads/master 89e6db615 -> 45861693b
[SPARK-10082][MLLIB] minor style updates for matrix indexing after #8271 * `>=0` => `>= 0` * print `i`, `j` in the log message MechCoder Author: Xiangrui Meng <[email protected]> Closes #9189 from mengxr/SPARK-10082. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/45861693 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/45861693 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/45861693 Branch: refs/heads/master Commit: 45861693bef2619196f0fbdf5c166ad3f9b1e8d1 Parents: 89e6db6 Author: Xiangrui Meng <[email protected]> Authored: Tue Oct 20 18:37:29 2015 -0700 Committer: Xiangrui Meng <[email protected]> Committed: Tue Oct 20 18:37:29 2015 -0700 ---------------------------------------------------------------------- .../main/scala/org/apache/spark/mllib/linalg/Matrices.scala | 8 ++++---- .../scala/org/apache/spark/mllib/linalg/MatricesSuite.scala | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/45861693/mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala ---------------------------------------------------------------------- diff --git a/mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala b/mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala index cfed9ad..8ba6e4e 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala @@ -296,8 +296,8 @@ class DenseMatrix @Since("1.3.0") ( override def apply(i: Int, j: Int): Double = values(index(i, j)) private[mllib] def index(i: Int, j: Int): Int = { - require(i < numRows && i >=0, s"Expected 0 <= i < $numRows, got $i") - require(j < numCols && j >=0, s"Expected 0 <= j < $numCols, got $j") + require(i >= 0 && i < numRows, s"Expected 0 <= i < $numRows, got i = $i.") + require(j >= 0 && j < numCols, s"Expected 0 <= j < $numCols, got j = $j.") if (!isTransposed) i + numRows * j else j + numCols * i } @@ -572,8 +572,8 @@ class SparseMatrix @Since("1.3.0") ( } private[mllib] def index(i: Int, j: Int): Int = { - require(i < numRows && i >=0, s"Expected 0 <= i < $numRows, got $i") - require(j < numCols && j >=0, s"Expected 0 <= j < $numCols, got $j") + require(i >= 0 && i < numRows, s"Expected 0 <= i < $numRows, got i = $i.") + require(j >= 0 && j < numCols, s"Expected 0 <= j < $numCols, got j = $j.") if (!isTransposed) { Arrays.binarySearch(rowIndices, colPtrs(j), colPtrs(j + 1), i) } else { http://git-wip-us.apache.org/repos/asf/spark/blob/45861693/mllib/src/test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala ---------------------------------------------------------------------- diff --git a/mllib/src/test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala b/mllib/src/test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala index b0071c9..1833cf3 100644 --- a/mllib/src/test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala +++ b/mllib/src/test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala @@ -78,10 +78,10 @@ class MatricesSuite extends SparkFunSuite { val sm = Matrices.sparse(3, 2, Array(0, 2, 3), Array(1, 2, 1), Array(0.0, 1.0, 2.0)) val dm = Matrices.dense(3, 2, Array(0.0, 2.3, 1.4, 3.2, 1.0, 9.1)) Array(sm, dm).foreach { mat => - intercept[IllegalArgumentException] { mat.index(4, 1) } - intercept[IllegalArgumentException] { mat.index(1, 4) } - intercept[IllegalArgumentException] { mat.index(-1, 2) } - intercept[IllegalArgumentException] { mat.index(1, -2) } + intercept[IllegalArgumentException] { mat.index(4, 1) } + intercept[IllegalArgumentException] { mat.index(1, 4) } + intercept[IllegalArgumentException] { mat.index(-1, 2) } + intercept[IllegalArgumentException] { mat.index(1, -2) } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
