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

Method test_logaddexp

python/tests/test_ops.py:921–942  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

919 self.assertTrue(np.allclose(result, expected))
920
921 def test_logaddexp(self):
922 a = mx.array([0, 1, 2, 9.0])
923 b = mx.array([1, 0, 4, 2.5])
924
925 result = mx.logaddexp(a, b)
926 expected = np.logaddexp(a, b, dtype=np.float32)
927
928 self.assertTrue(np.allclose(result, expected))
929
930 # Complex test
931
932 a = mx.array([0, 1, 2, 9.0]) + 1j
933 b = mx.array([1, 0, 4, 2.5]) + 1j
934
935 result = mx.logaddexp(a, b)
936 expected = np_logaddexp(np.array(a), np.array(b))
937
938 self.assertTrue(np.allclose(result, expected))
939
940 a = mx.array([float("nan")])
941 b = mx.array([0.0])
942 self.assertTrue(math.isnan(mx.logaddexp(a, b).item()))
943
944 def test_log(self):
945 a = mx.array([1, 0.5, 10, 100])

Callers

nothing calls this directly

Calls 3

np_logaddexpFunction · 0.85
itemMethod · 0.80
arrayMethod · 0.60

Tested by

no test coverage detected