Equal weights with uniform blocks should produce 50/50 every 2 blocks. If weights are not provided, they should default to 1.0.
(ray_start_10_cpus_shared, weights)
| 19 | |
| 20 | @pytest.mark.parametrize("weights", [[1, 1], None]) |
| 21 | def test_mix_equal_weights(ray_start_10_cpus_shared, weights): |
| 22 | """Equal weights with uniform blocks should produce 50/50 every 2 blocks. |
| 23 | If weights are not provided, they should default to 1.0. |
| 24 | """ |
| 25 | rows_per_block = 10 |
| 26 | ds1 = _make_ds(source_id=0, num_rows=500, rows_per_block=rows_per_block) |
| 27 | ds2 = _make_ds(source_id=1, num_rows=500, rows_per_block=rows_per_block) |
| 28 | mixed = ds1.mix( |
| 29 | ds2, |
| 30 | weights=weights, |
| 31 | stopping_condition=MixStoppingCondition.STOP_ON_LONGEST_DROP, |
| 32 | ) |
| 33 | # We should round robin between the two datasets. |
| 34 | # The output should alternate 10 rows for each dataset. |
| 35 | for batch in mixed.iter_batches(batch_size=2 * rows_per_block): |
| 36 | ratio = np.sum(batch["source"] == 0) / len(batch["source"]) |
| 37 | assert ratio == 0.5 |
| 38 | |
| 39 | |
| 40 | def test_mix_uneven_weights(ray_start_10_cpus_shared): |
nothing calls this directly
no test coverage detected
searching dependent graphs…