Пример #1
0
def test_abstact_continuous_encode_decode():
    h1 = hp.AbstractContinuousHyperParameter('h1', 0.0, 1.0)

    encoded = h1.encode(0.5)
    assert encoded == 0.5

    decoded = h1.decode(encoded)
    assert decoded == 0.5
Пример #2
0
def test_abstract_continuous():
    h1 = hp.AbstractContinuousHyperParameter('h1', 0.0, 1.0)

    assert h1.name == 'h1'
    assert h1.num_choices == 0
    assert h1._val1 == 0.0
    assert h1._val2 == 1.0
    assert repr(h1)
Пример #3
0
def test_abstract_continuous_log_space_encode_decode():
    h1 = hp.AbstractContinuousHyperParameter('h1', 0.0, 1.0, log_encode=True)

    encoded = h1.encode(0.5)
    assert encoded == -0.6931471805599453

    decoded = h1.decode(encoded)
    assert decoded == 0.5

    encoded = h1.encode(0.0)
    assert encoded == -np.inf

    decoded = h1.decode(encoded)
    assert decoded == 0.0
Пример #4
0
def test_abstract_continuous_sample():
    h1 = hp.AbstractContinuousHyperParameter('h1', 0.0, 1.0)

    with pytest.raises(NotImplementedError):
        sample = h1.sample()
Пример #5
0
def test_abstract_continuous_no_values():
    with pytest.raises(ValueError):
        hp.AbstractContinuousHyperParameter(None, 0, 1)

    with pytest.raises(ValueError):
        hp.AbstractContinuousHyperParameter('h1', None, None)