def test_sample_discrete():
rng = np.random.default_rng()
outcomes = ["foo", "bar.com"]
# Test basic functionality
values = dists.sample_discrete([",".join(outcomes)], rng.uniform(size=10))
assert all(value in outcomes for value in values)
# Test empty case
assert not dists.sample_discrete([",".join(outcomes)], np.array([])).size
# Test weighted case where only bar.com should appear
assert "foo" not in dists.sample_discrete(
[",".join(outcomes), "0,1"], rng.uniform(size=10)
)
# Test weights that don't sum to 1
weighted_values = dists.sample_discrete(
[",".join(outcomes), "2,6"], rng.uniform(size=100)
)
# Should see roughly 25% foo and 75% bar.com
foo_count = np.sum(weighted_values == "foo")
> assert 15 <= foo_count <= 35 # Allow some variance due to randomness
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E assert np.int64(39) <= 35
What happened? (You can include a screenshot if it helps explain)
PR semeio test fails
What did you expect to happen?
Test should pass
Steps to reproduce
Environment where bug has been observed