Esempio n. 1
0
def test__get_rand_with_random_state_with_state():

    random_state = check_random_state(123)
    hp = HyperRangeInt(0, 2, random_state=random_state)

    assert len(set([hp.get_rand() for _ in range(10)])) > 1  # different values
    assert len(set([_get_rand(["a", "b", "c"], random_state=random_state) for _ in range(10)])) > 1
    assert len(set([_get_rand(randint(1, 3), random_state=random_state) for _ in range(10)])) > 1
Esempio n. 2
0
def test_HyperRangeBetaInt():
    hp = HyperRangeInt(10, 100, random_state=123)

    all_x = []
    for _ in range(100):
        x = hp.get_rand()
        assert isinstance(x, int)
        assert x >= 10
        assert x <= 100
        all_x.append(x)

    assert len(set(all_x)) > 1
Esempio n. 3
0
def test_HyperRangeInt():
    hp = HyperRangeInt(10, 100, step=10, random_state=123)
    possible_choices = set([10 * (i + 1) for i in range(10)])
    all_x = []
    for _ in range(100):
        x = hp.get_rand()
        assert isinstance(x, int)
        assert x >= 10
        assert x <= 100
        assert x in possible_choices
        all_x.append(x)

    assert len(set(all_x)) > 1  # I don't want always the same value