MCPcopy Create free account
hub / github.com/ml-explore/mlx / assertEqualArray

Method assertEqualArray

python/tests/mlx_tests.py:100–124  ·  view source on GitHub ↗
(
        self,
        mx_res: mx.array,
        expected: mx.array,
        atol=1e-2,
        rtol=1e-2,
    )

Source from the content-addressed store, hash-verified

98 return self.assertEqualArray(mx_res, mx.array(np_res), atol=atol, rtol=rtol)
99
100 def assertEqualArray(
101 self,
102 mx_res: mx.array,
103 expected: mx.array,
104 atol=1e-2,
105 rtol=1e-2,
106 ):
107 self.assertEqual(
108 tuple(mx_res.shape),
109 tuple(expected.shape),
110 msg=f"shape mismatch expected={expected.shape} got={mx_res.shape}",
111 )
112 self.assertEqual(
113 mx_res.dtype,
114 expected.dtype,
115 msg=f"dtype mismatch expected={expected.dtype} got={mx_res.dtype}",
116 )
117 if not isinstance(mx_res, mx.array) and not isinstance(expected, mx.array):
118 np.testing.assert_allclose(mx_res, expected, rtol=rtol, atol=atol)
119 return
120 elif not isinstance(mx_res, mx.array):
121 mx_res = mx.array(mx_res)
122 elif not isinstance(expected, mx.array):
123 expected = mx.array(expected)
124 self.assertTrue(mx.allclose(mx_res, expected, rtol=rtol, atol=atol))

Callers 15

assertCmpNumpyMethod · 0.95
test_sigmoidMethod · 0.80
test_preluMethod · 0.80
test_mishMethod · 0.80
test_gluMethod · 0.80
test_array_pickleMethod · 0.80
test_array_copyMethod · 0.80
test_array_atMethod · 0.80
test_buffer_protocolMethod · 0.80

Calls 1

arrayMethod · 0.60

Tested by

no test coverage detected