HyukjinKwon commented on code in PR #59485:
URL: https://github.com/apache/spark/pull/59485#discussion_r4286389631


##########
mllib-local/src/test/scala/org/apache/spark/ml/linalg/MatricesSuite.scala:
##########
@@ -870,6 +1009,54 @@ class MatricesSuite extends SparkMLFunSuite {
     assert(lines.length == 5 && lines.forall(_.length <= 100))
   }
 
+  test("matrix formatting preserves Breeze layout and truncation") {
+    val dense = new DenseMatrix(3, 4,
+      Array(0.0, -0.0, 1.0, 12.0, -123.0, 1e100, Double.NaN,
+        Double.PositiveInfinity, Double.NegativeInfinity, 0.01, 0.0, 3.0))
+    val sparse = new SparseMatrix(3, 4, Array(0, 2, 2, 4, 5),
+      Array(0, 2, 0, 1, 2), Array(-0.0, 1.0, Double.NaN, 0.0, 
Double.PositiveInfinity))
+    val tall = new DenseMatrix(85, 1, Array.tabulate(85)(_.toDouble))
+    val matrices = Seq(dense, sparse, dense.transpose, sparse.transpose,

Review Comment:
   **Nit (P3):** Every dense matrix in this default-`toString` parity list 
renders far below the 80-character width. The widest row is about 32 characters 
(the 3x4 fixture), and the mllib and locale tests add no wide dense case 
either. So the Spark-owned default in `MatrixFormatter.format(matrix)` 
(`format(matrix, maxLines, 80)`) is never exercised. If that `80` changed, 
every assertion here would still pass while the default rendering of wide 
matrices changed. Adding a wide dense fixture such as `DenseMatrix.ones(2, 30)` 
to this list would pin the default column truncation and the `... (30 total)` 
marker.
   
   **Verification:**
   - **Regression:** Default toString of a dense matrix wider than 80 
characters matches the Breeze rendering, including column truncation and the 
'... (N total)' marker, and would differ if the default width were changed.
   - **Behavior:** The existing mllib-local matrix formatting, equality, 
hashing, and sparse layout conversion parity tests still pass.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to