Regression: split with num_splits <= 0 should raise, not crash.
(self)
| 1329 | self.assertEqual(z.tolist(), [5, 6, 7]) |
| 1330 | |
| 1331 | def test_split_invalid_num_splits(self): |
| 1332 | """Regression: split with num_splits <= 0 should raise, not crash.""" |
| 1333 | a = mx.arange(6) |
| 1334 | |
| 1335 | # num_splits = 0: should raise cleanly (was UB via divide-by-zero) |
| 1336 | with self.assertRaises(ValueError): |
| 1337 | mx.split(a, 0) |
| 1338 | |
| 1339 | # num_splits = -1: should raise cleanly (was SIGBUS via huge allocation) |
| 1340 | with self.assertRaises(ValueError): |
| 1341 | mx.split(a, -1) |
| 1342 | |
| 1343 | # Also check with explicit axis |
| 1344 | b = mx.zeros((4, 6)) |
| 1345 | with self.assertRaises(ValueError): |
| 1346 | mx.split(b, 0, axis=1) |
| 1347 | with self.assertRaises(ValueError): |
| 1348 | mx.split(b, -2, axis=0) |
| 1349 | |
| 1350 | def test_arange_overload_dispatch(self): |
| 1351 | with self.assertRaises(ValueError): |