I'm referring to the ndarray crate as well as the assert_approx_eq.
My question: Does something like assert_approx_eq exist for ndarray::Array2 etc.?
Currently I'm doing:
for it in mat_a.iter().zip(expect_mat_a.iter()) {
let (af, bf) = it;
assert_approx_eq!(af, bf);
}
This is works, but is sub-optimal.
Yes, ndarray has the optional feature approx and with it enabled, it supports the approx crate traits and macros.
use approx::assert_abs_diff_eq;
assert_abs_diff_eq!(af, bf);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With