mlx_rs/macros/assert.rs
1/// Asserts that two arrays are equal.
2///
3/// It checks that the two arrays have the same shape and that all elements are
4/// sufficiently close.
5///
6/// This legacy macro does not compare dtypes and uses its tolerance as both `rtol` and `atol`.
7/// Workspace tests should use [`crate::test_utils::assert_array_eq`] for strict comparisons.
8#[macro_export]
9macro_rules! assert_array_eq {
10 ($value:expr, $expected:expr) => {
11 assert_array_eq!($value, $expected, None);
12 };
13 ($value:expr, $expected:expr, $atol:expr) => {
14 assert_eq!($value.shape(), $expected.shape(), "Shapes are not equal");
15 let assert = $value.all_close(&$expected, $atol, $atol, None);
16 assert!(assert.unwrap(), "Values are not sufficiently close");
17 };
18}