arrayfire / arrayfire-haskell

Haskell bindings to ArrayFire
http://hackage.haskell.org/package/arrayfire
BSD 3-Clause "New" or "Revised" License
59 stars 5 forks source link

Relax some tests that are satisfied only up to some floating point error. #59

Closed leftaroundabout closed 4 months ago

leftaroundabout commented 4 months ago

It is actually surprising how many tests hold exactly, with standard equality. But not all of them do. Prior to this fix:

Failures:

  test/ArrayFire/LAPACKSpec.hs:36:9: 
  1) ArrayFire.LAPACK, LAPACK spec, Should get determinant of Double
       expected: -14.0
        but got: -13.999999999999996

  To rerun use: --match "/ArrayFire.LAPACK/LAPACK spec/Should get determinant of Double/" --seed 882460504

  test/ArrayFire/StatisticsSpec.hs:18:9: 
  2) ArrayFire.Statistics, Statistics spec, Should find the weighted-mean
       expected: ArrayFire Array
                 [1 1 1 1]
                     7.0000 

        but got: ArrayFire Array
                 [1 1 1 1]
                     7.0000 

This is due to ordinary and inevitable inexactness of floating point calculations (in the latter case, the error is so small it doesn't even appear in the printed result), and it should not be counted as a failure of the test suite.

This PR makes these two tests lenient WRT such small float deviations.

leftaroundabout commented 4 months ago

This fixes #49