I am trying to write tests for various algorithms in my crate. However, I have come across a bit of a hurdle regarding how f64 values behave. They both return the same value, but I'm not too sure of the precision of the calculated series, because the assertion fails.
fn floating_point() {
let s1 = Series::new("a", vec![1.0, 5.0, 7.7]);
let s2 = Series::new("a", vec![4.566667]);
let avg = s1.mean_as_series();
println!("{}", avg);
println!("{}", s2);
assert!(s2.series_equal(&avg))
}
shape: (1,)
Series: 'a' [f64]
[
4.566667
]
shape: (1,)
Series: 'a' [f64]
[
4.566667
]
What would be the recommended way to determine if 2 series like this are equivalent? I have looked into rounding the series, but I am looking for alternatives to that. The behaviour seems to be inconsistent with 5 decimal points on different series. some fail, some pass.
Also, what would be the way to do this with a Dataframe without extracting the series?