Github user dbtsai commented on the pull request:

    https://github.com/apache/spark/pull/1425#issuecomment-49954543
  
    @srowen @mengxr and @dorx
    
    Based on our discussion, I've implemented two different APIs for relative 
error, and absolute error. It makes sense that test writers should know which 
one they need depending on their circumstances. 
    
    Developers also need to explicitly specify the eps now, and there is no 
default value which will sometimes cause confusion. 
    
    When comparing against zero using relative error, a exception will be 
raised to warn users that it's meaningless.
    
    For relative error in percentage, users can now write 
    
        assert(23.1 ~== 23.52 %+- 2.0)
        assert(23.1 ~== 22.74 %+- 2.0)
        assert(23.1 ~= 23.52 %+- 2.0)
        assert(23.1 ~= 22.74 %+- 2.0)
        assert(!(23.1 !~= 23.52 %+- 2.0))
        assert(!(23.1 !~= 22.74 %+- 2.0))
    
        // This will throw exception with the following message.
        // "Did not expect 23.1 and 23.52 to be within 2.0% using relative 
error."
        assert(23.1 !~== 23.52 %+- 2.0)
    
        // "Expected 23.1 and 22.34 to be within 2.0% using relative error."
        assert(23.1 ~== 22.34 %+- 2.0)
          
    For absolute error, 
    
        assert(17.8 ~== 17.99 +- 0.2)
        assert(17.8 ~== 17.61 +- 0.2)
        assert(17.8 ~= 17.99 +- 0.2)
        assert(17.8 ~= 17.61 +- 0.2)
        assert(!(17.8 !~= 17.99 +- 0.2))
        assert(!(17.8 !~= 17.61 +- 0.2))
    
        // This will throw exception with the following message.
        // "Did not expect 17.8 and 17.99 to be within 0.2 using absolute 
error."
        assert(17.8 !~== 17.99 +- 0.2)
         
        // "Expected 17.8 and 17.59 to be within 0.2 using absolute error."
        assert(17.8 ~== 17.59 +- 0.2)



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to