Skip to content

Commit 82e6a3d

Browse files
committed
Add more tests for stable_random_distribution
1 parent 37cc4bf commit 82e6a3d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

micall/tests/test_stable_random_distribution.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
from micall.utils.stable_random_distribution import stable_random_distribution
33
import numpy as np
4+
from itertools import islice
45

56

67
def test_indices_in_range():
@@ -15,6 +16,17 @@ def test_indices_in_range():
1516
assert 0 <= idx < maximum, f"Index {idx} out of range [0,{maximum})"
1617

1718

19+
def test_bounds_are_reachable():
20+
"""Test that both min and max-1 can be generated."""
21+
22+
maximum = 999
23+
gen = stable_random_distribution(maximum, seed=123)
24+
lst = islice(gen, 1000)
25+
26+
assert 0 in lst
27+
assert (maximum-1) in lst
28+
29+
1830
def test_deterministic_output_with_seed():
1931
"""
2032
Test that the generator produces the same sequence when
@@ -65,7 +77,7 @@ def test_fair_distribution_behavior():
6577
"""
6678

6779
maximum = 1_000
68-
num_samples = 10_000
80+
num_samples = 3_000
6981
for seed in range(100):
7082
# Gather samples from our generator.
7183
gen = stable_random_distribution(maximum, seed=seed)

0 commit comments

Comments
 (0)