Skip to content
Snippets Groups Projects
Commit 40168dbe authored by Peng, Meng's avatar Peng, Meng Committed by Sean Owen
Browse files

[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.
parent cd0ed31e
No related branches found
No related tags found
No related merge requests found
......@@ -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}")
......
......@@ -572,10 +572,13 @@ class SparseMatrix @Since("1.3.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}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment