[ 
https://issues.apache.org/jira/browse/SPARK-2599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14070929#comment-14070929
 ] 

DB Tsai commented on SPARK-2599:
--------------------------------

I'm the original guy implementing `almostEquals` for my unit-testing, and I 
also noticed that it will be suffering when comparing against 0.0. As [~srowen] 
pointed out, it's meaningless to comparing against 0.0 (or a really small 
number) with relative error. However, people may just want to write unittest 
using relative error for even comparing those small numbers. So I purpose the 
following APIs.

`a ~== b +- eps` for relative error, and when a or b near zero, let's say 
1e-15, it falls back to absolute error.
`a === b +- eps` which is already in scalatest 2.0 for absolute error, but 
since we don't use scalatest 2.0 yet, we build the same APIs in mllib for 
absolute error.

> almostEquals mllib.util.TestingUtils does not behave as expected when 
> comparing against 0.0
> -------------------------------------------------------------------------------------------
>
>                 Key: SPARK-2599
>                 URL: https://issues.apache.org/jira/browse/SPARK-2599
>             Project: Spark
>          Issue Type: Bug
>          Components: MLlib
>            Reporter: Doris Xin
>            Priority: Minor
>
> DoubleWithAlmostEquals.almostEquals, when used to compare a number with 0.0, 
> would always produce an epsilon of 1 >> 1e-10, causing false failure when 
> comparing very small numbers with 0.0.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to