diff options
author | Peng, Meng <peng.meng@intel.com> | 2016-08-27 08:46:01 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-08-27 08:46:01 +0100 |
commit | 40168dbe771ae662ed61851a1f3c677dd14fe344 (patch) | |
tree | aefddcd0112f6911314a6f621f41da638bda9b72 /mllib-local | |
parent | cd0ed31ea9965563a9b1ea3e8bfbeaf8347cacd9 (diff) | |
download | spark-40168dbe771ae662ed61851a1f3c677dd14fe344.tar.gz spark-40168dbe771ae662ed61851a1f3c677dd14fe344.tar.bz2 spark-40168dbe771ae662ed61851a1f3c677dd14fe344.zip |
[ML][MLLIB] The require condition and message doesn't match in SparseMatrix.
## What changes were proposed in this pull request?
The require condition and message doesn't match, and the condition also should be optimized.
Small change. Please kindly let me know if JIRA required.
## How was this patch tested?
No additional test required.
Author: Peng, Meng <peng.meng@intel.com>
Closes #14824 from mpjlu/smallChangeForMatrixRequire.
Diffstat (limited to 'mllib-local')
-rw-r--r-- | mllib-local/src/main/scala/org/apache/spark/ml/linalg/Matrices.scala | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Matrices.scala b/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Matrices.scala index 0ea687bbcc..f1ecc65af1 100644 --- a/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Matrices.scala +++ b/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Matrices.scala @@ -454,10 +454,13 @@ class SparseMatrix @Since("2.0.0") ( require(values.length == rowIndices.length, "The number of row indices and values don't match! " + s"values.length: ${values.length}, rowIndices.length: ${rowIndices.length}") - // The Or statement is for the case when the matrix is transposed - require(colPtrs.length == numCols + 1 || colPtrs.length == numRows + 1, "The length of the " + - "column indices should be the number of columns + 1. Currently, colPointers.length: " + - s"${colPtrs.length}, numCols: $numCols") + if (isTransposed) { + require(colPtrs.length == numRows + 1, + s"Expecting ${numRows + 1} colPtrs when numRows = $numRows but got ${colPtrs.length}") + } else { + require(colPtrs.length == numCols + 1, + s"Expecting ${numCols + 1} colPtrs when numCols = $numCols but got ${colPtrs.length}") + } require(values.length == colPtrs.last, "The last value of colPtrs must equal the number of " + s"elements. values.length: ${values.length}, colPtrs.last: ${colPtrs.last}") |