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

Method test_to_scalar

python/tests/test_array.py:2166–2179  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2164 self.assertEqual(mx.asarray(42, dtype=mx.float16).dtype, mx.float16)
2165
2166 def test_to_scalar(self):
2167 a = mx.array(1)
2168 self.assertEqual(int(a), 1)
2169 self.assertEqual(float(a), 1)
2170
2171 a = mx.array(1.5)
2172 self.assertEqual(float(a), 1.5)
2173 self.assertEqual(int(a), 1)
2174
2175 a = mx.zeros((2, 1))
2176 with self.assertRaises(ValueError):
2177 float(a)
2178 with self.assertRaises(ValueError):
2179 int(a)
2180
2181 def test_format(self):
2182 a = mx.arange(3)

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.60

Tested by

no test coverage detected