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

Method test_split_invalid_num_splits

python/tests/test_ops.py:1331–1348  ·  view source on GitHub ↗

Regression: split with num_splits <= 0 should raise, not crash.

(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected