Skip to content

Commit 810f97f

Browse files
committed
fix equal of matrix
1 parent 032cd62 commit 810f97f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.spark.mllib.linalg
1919

20+
import java.util
21+
2022
import breeze.linalg.{Matrix => BM, DenseMatrix => BDM}
2123

2224
/**
@@ -66,8 +68,8 @@ class DenseMatrix(val numRows: Int, val numCols: Int, val values: Array[Double])
6668
private[mllib] override def toBreeze: BM[Double] = new BDM[Double](numRows, numCols, values)
6769

6870
override def equals(o: Any) = o match {
69-
case that: DenseMatrix =>
70-
that.numRows == numRows && that.numCols == numCols && values.equals(that.values)
71+
case m: DenseMatrix =>
72+
m.numRows == numRows && m.numCols == numCols && util.Arrays.equals(toArray, m.toArray)
7173
case _ => false
7274
}
7375
}

mllib/src/test/scala/org/apache/spark/mllib/api/python/PythonMLLibAPISuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class PythonMLLibAPISuite extends FunSuite {
7070
val values = Array[Double](0, 1.2, 3, 4.56, 7, 8)
7171
val matrix = Matrices.dense(2, 3, values)
7272
val nm = SerDe.loads(SerDe.dumps(matrix)).asInstanceOf[DenseMatrix]
73-
assert(matrix == nm)
73+
assert(matrix === nm)
7474

7575
// Test conversion for empty matrix
7676
val empty = Array[Double]()

0 commit comments

Comments
 (0)