macro_rules! assert_array_eq {
($value:expr, $expected:expr) => { ... };
($value:expr, $expected:expr, $atol:expr) => { ... };
}👎Deprecated since 0.33.0:
use Array::all_close with separate rtol and atol arguments and an explicit dtype check
Expand description
Asserts that two arrays have the same shape and sufficiently close elements.
This macro ignores dtype. Its optional third argument is passed as both rtol
and atol to Array::all_close; omitting it uses
that method’s default tolerances. It panics if the shapes differ, the values
are not sufficiently close, or the comparison returns an error.
Use Array::all_close with separate rtol and
atol arguments, plus explicit shape and dtype checks:
use mlx_rs::array;
let actual = array!([1.0_f32, 2.0]);
let expected = array!([1.0_f32, 2.0]);
assert_eq!(actual.shape(), expected.shape());
assert_eq!(actual.dtype(), expected.dtype());
assert!(actual.all_close(&expected, Some(1e-5), Some(1e-8), None).unwrap());