You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by me...@apache.org on 2016/03/28 17:33:42 UTC
spark git commit: [SPARK-14187][MLLIB] Fix incorrect use of
binarySearch in SparseMatrix
Repository: spark
Updated Branches:
refs/heads/master b66aa9006 -> c8388297c
[SPARK-14187][MLLIB] Fix incorrect use of binarySearch in SparseMatrix
## What changes were proposed in this pull request?
Fix incorrect use of binarySearch in SparseMatrix
## How was this patch tested?
Unit test added.
Author: Chenliang Xu <ch...@groupon.com>
Closes #11992 from luckyrandom/SPARK-14187.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/c8388297
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/c8388297
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/c8388297
Branch: refs/heads/master
Commit: c8388297c436691a236520d2396deaf556aedb0e
Parents: b66aa90
Author: Chenliang Xu <ch...@groupon.com>
Authored: Mon Mar 28 08:33:37 2016 -0700
Committer: Xiangrui Meng <me...@databricks.com>
Committed: Mon Mar 28 08:33:37 2016 -0700
----------------------------------------------------------------------
.../src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala | 2 +-
.../test/scala/org/apache/spark/mllib/linalg/MatricesSuite.scala | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/c8388297/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 c6de775..a09bc65 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
@@ -613,7 +613,7 @@ class SparseMatrix @Since("1.3.0") (
private[mllib] def update(i: Int, j: Int, v: Double): Unit = {
val ind = index(i, j)
- if (ind == -1) {
+ if (ind < 0) {
throw new NoSuchElementException("The given row and column indices correspond to a zero " +
"value. Only non-zero elements in Sparse Matrices can be updated.")
} else {
http://git-wip-us.apache.org/repos/asf/spark/blob/c8388297/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 a02b8c9..57907f4 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
@@ -150,6 +150,10 @@ class MatricesSuite extends SparkFunSuite {
sparseMat.update(0, 0, 10.0)
}
+ intercept[NoSuchElementException] {
+ sparseMat.update(2, 1, 10.0)
+ }
+
sparseMat.update(0, 1, 10.0)
assert(sparseMat(0, 1) === 10.0)
assert(sparseMat.values(2) === 10.0)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org