tsurucapital / piecewise-polynomial-rust

Rust port of https://github.com/tsurucapital/piecewise-polynomial/
1 stars 2 forks source link

Use the approx crate when comparing floats #2

Closed maoe closed 3 years ago

maoe commented 3 years ago

We use assert_eq! on floats in the tests. We should instead use the approx crate.

Fuuzetsu commented 3 years ago

We already use assert_approx_eq! in some places. The reason for assert_eq remaining was that all the tests were first ran in our Haskell version, the numbers copied in verbatim and then ran against the Rust implementation. If it matched exactly, it was kept-as is.

Then as small changes were being made such as use of mul_add, some results started to change when compared to the Haskell implementation: usually for the better accuracy. These were changed to assert_approx_eq as needed.

We can change them all though it becomes a bit weaker as to what it is testing which currently is "exactly same accuracy as Haskell implementation on my machine". I'm ok with changing them now that we're fairly confident in the faithfulness of the implementation though.

maoe commented 3 years ago

It turned out that small numerical differences could be important for us. I'm closing this.