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

Method test_arange_overload_dispatch

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

Source from the content-addressed store, hash-verified

1348 mx.split(b, -2, axis=0)
1349
1350 def test_arange_overload_dispatch(self):
1351 with self.assertRaises(ValueError):
1352 a = mx.arange(float("nan"), 1, 5)
1353 with self.assertRaises(ValueError):
1354 a = mx.arange(0, float("nan"), 5)
1355 with self.assertRaises(ValueError):
1356 a = mx.arange(0, 2, float("nan"))
1357 with self.assertRaises(ValueError):
1358 a = mx.arange(0, float("inf"), float("inf"))
1359 with self.assertRaises(ValueError):
1360 a = mx.arange(float("inf"), 1, float("inf"))
1361 with self.assertRaises(ValueError):
1362 a = mx.arange(float("inf"), 1, 5)
1363 with self.assertRaises(TypeError):
1364 INT_MAX = 2147483647
1365 a = mx.arange(0, INT_MAX + 1, 1)
1366
1367 a = mx.arange(5)
1368 expected = [0, 1, 2, 3, 4]
1369 self.assertListEqual(a.tolist(), expected)
1370
1371 a = mx.arange(1, 5)
1372 expected = [1, 2, 3, 4]
1373 self.assertListEqual(a.tolist(), expected)
1374
1375 a = mx.arange(-3, step=-1)
1376 expected = [0, -1, -2]
1377 self.assertListEqual(a.tolist(), expected)
1378
1379 a = mx.arange(stop=2, step=0.5)
1380 expected = [0, 0.5, 1.0, 1.5]
1381 self.assertListEqual(a.tolist(), expected)
1382
1383 with self.assertRaises(TypeError):
1384 mx.arange(start=1, step=2)
1385
1386 a = mx.arange(stop=3)
1387 expected = [0, 1, 2]
1388 self.assertListEqual(a.tolist(), expected)
1389
1390 def test_arange_inferred_dtype(self):
1391 a = mx.arange(5)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected