(ray_start_regular_shared_2_cpus)
| 307 | |
| 308 | |
| 309 | def 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 | |
| 347 | def test_split(ray_start_regular_shared_2_cpus): |
nothing calls this directly
no test coverage detected
searching dependent graphs…