zhengruifeng commented on a change in pull request #30587:
URL: https://github.com/apache/spark/pull/30587#discussion_r535121974
##########
File path:
mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala
##########
@@ -2962,7 +2962,14 @@ object LogisticRegressionSuite {
def checkCoefficientsEquivalent(coefficients1: Matrix, coefficients2:
Matrix): Unit = {
coefficients1.colIter.zip(coefficients2.colIter).foreach { case (col1:
Vector, col2: Vector) =>
(col1.asBreeze - col2.asBreeze).toArray.toSeq.sliding(2).foreach {
- case Seq(v1, v2) => assert(v1 ~= v2 absTol 1E-3)
+ case Seq(v1, v2) =>
+ if (math.abs(v1) < 1E-5 || math.abs(v2) < 1E-5) {
+ // If one of v1 and v2 is very close to zero, then compare absTol
+ assert(v1 ~= v2 absTol 1E-2, s"v1 ~= v2 absTol 0.01 faild:
v1=${v1}, v2=${v2}")
+ }
+ else {
+ assert(v1 ~= v2 relTol 1E-2, s"v1 ~= v2 relTol 0.01 faild:
v1=${v1}, v2=${v2}")
Review comment:
I guess you can keep previous logic `v1 ~= v2 absTol 1E-3` here.
##########
File path:
mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala
##########
@@ -2962,7 +2962,14 @@ object LogisticRegressionSuite {
def checkCoefficientsEquivalent(coefficients1: Matrix, coefficients2:
Matrix): Unit = {
coefficients1.colIter.zip(coefficients2.colIter).foreach { case (col1:
Vector, col2: Vector) =>
(col1.asBreeze - col2.asBreeze).toArray.toSeq.sliding(2).foreach {
- case Seq(v1, v2) => assert(v1 ~= v2 absTol 1E-3)
+ case Seq(v1, v2) =>
+ if (math.abs(v1) < 1E-5 || math.abs(v2) < 1E-5) {
+ // If one of v1 and v2 is very close to zero, then compare absTol
+ assert(v1 ~= v2 absTol 1E-2, s"v1 ~= v2 absTol 0.01 faild:
v1=${v1}, v2=${v2}")
+ }
Review comment:
nit: lint
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]