MCPcopy
hub / github.com/ray-project/ray / test_split_proportionately

Function test_split_proportionately

python/ray/data/tests/test_split.py:309–344  ·  view source on GitHub ↗
(ray_start_regular_shared_2_cpus)

Source from the content-addressed store, hash-verified

307
308
309def test_split_proportionately(ray_start_regular_shared_2_cpus):
310 ds = ray.data.range(10, override_num_blocks=3)
311
312 with pytest.raises(ValueError):
313 ds.split_proportionately([])
314
315 with pytest.raises(ValueError):
316 ds.split_proportionately([-1])
317
318 with pytest.raises(ValueError):
319 ds.split_proportionately([0])
320
321 with pytest.raises(ValueError):
322 ds.split_proportionately([1])
323
324 with pytest.raises(ValueError):
325 ds.split_proportionately([0.5, 0.5])
326
327 splits = ds.split_proportionately([0.5])
328 r = [extract_values("id", s.take()) for s in splits]
329 assert r == [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
330
331 splits = ds.split_proportionately([0.2, 0.3])
332 r = [extract_values("id", s.take()) for s in splits]
333 assert r == [[0, 1], [2, 3, 4], [5, 6, 7, 8, 9]]
334
335 splits = ds.split_proportionately([0.2, 0.3, 0.3])
336 r = [extract_values("id", s.take()) for s in splits]
337 assert r == [[0, 1], [2, 3, 4], [5, 6, 7], [8, 9]]
338
339 splits = ds.split_proportionately([0.98, 0.01])
340 r = [extract_values("id", s.take()) for s in splits]
341 assert r == [[0, 1, 2, 3, 4, 5, 6, 7], [8], [9]]
342
343 with pytest.raises(ValueError):
344 ds.split_proportionately([0.90] + ([0.001] * 90))
345
346
347def test_split(ray_start_regular_shared_2_cpus):

Callers

nothing calls this directly

Calls 3

extract_valuesFunction · 0.90
split_proportionatelyMethod · 0.80
takeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…