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

Method test_uniform

python/tests/test_random.py:44–65  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

42 self.assertEqual(keys.shape, (10, 2))
43
44 def test_uniform(self):
45 key = mx.random.key(0)
46 a = mx.random.uniform(key=key)
47 self.assertEqual(a.shape, ())
48 self.assertEqual(a.dtype, mx.float32)
49
50 b = mx.random.uniform(key=key)
51 self.assertEqual(a.item(), b.item())
52
53 a = mx.random.uniform(shape=(2, 3))
54 self.assertEqual(a.shape, (2, 3))
55
56 a = mx.random.uniform(shape=(1000,), low=-1, high=5)
57 self.assertTrue(mx.all((a > -1) < 5).item())
58
59 a = mx.random.uniform(shape=(1000,), low=mx.array(-1), high=5)
60 self.assertTrue(mx.all((a > -1) < 5).item())
61
62 a = mx.random.uniform(low=-0.1, high=0.1, shape=(1,), dtype=mx.bfloat16)
63 self.assertEqual(a.dtype, mx.bfloat16)
64
65 self.assertEqual(mx.random.uniform().dtype, mx.random.uniform(dtype=None).dtype)
66
67 def test_normal_and_laplace(self):
68 # Same tests for normal and laplace.

Callers

nothing calls this directly

Calls 2

itemMethod · 0.80
arrayMethod · 0.60

Tested by

no test coverage detected