mlx_rs/macros/
assert.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// Asserts that two arrays are equal.
///
/// It checks that the two arrays have the same shape and that all elements are
/// sufficiently close.
#[macro_export]
macro_rules! assert_array_eq {
    ($value:expr, $expected:expr) => {
        assert_array_eq!($value, $expected, None);
    };
    ($value:expr, $expected:expr, $atol:expr) => {
        assert_eq!($value.shape(), $expected.shape(), "Shapes are not equal");
        let assert = $value.all_close(&$expected, $atol, $atol, None);
        assert!(
            assert.unwrap().item::<bool>(),
            "Values are not sufficiently close"
        );
    };
}