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

Function test_mix_equal_weights

python/ray/data/tests/test_mix.py:21–37  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

19
20@pytest.mark.parametrize("weights", [[1, 1], None])
21def 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
40def test_mix_uneven_weights(ray_start_10_cpus_shared):

Callers

nothing calls this directly

Calls 4

_make_dsFunction · 0.85
mixMethod · 0.80
iter_batchesMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…