Ejemplo n.º 1
0
def test_discrete_parameter():
    param = DiscreteParameter('x', [0, 1, 2])
    assert param.name == 'x'
    assert param.check_in_domain(np.array([0, 1])) is True
    assert param.check_in_domain(np.array([3])) is False
    assert param.check_in_domain(np.array([[1], [0]])) is True
    assert param.check_in_domain([1, 0]) is True
    assert param.check_in_domain(1) is True
    assert param.check_in_domain(0.5) is False

    with pytest.raises(ValueError):  # too many columns
        param.check_in_domain(np.array([[1, 0], [0, 2]]))
    with pytest.raises(ValueError):  # not a 1d/2d array
        param.check_in_domain(np.array([[[1]]]))
Ejemplo n.º 2
0
def test_discrete_parameter():
    param = DiscreteParameter('x', [0, 1, 2])
    assert param.name == 'x'
    assert param.check_in_domain(np.array([0, 1])) is True
    assert param.check_in_domain(np.array([3])) is False
    assert param.check_in_domain(np.array([[1], [0]])) is True
    assert param.check_in_domain([1, 0]) is True
    assert param.check_in_domain(1) is True
    assert param.check_in_domain(0.5) is False

    with pytest.raises(ValueError):  # too many columns
        param.check_in_domain(np.array([[1, 0], [0, 2]]))
    with pytest.raises(ValueError):  # not a 1d/2d array
        param.check_in_domain(np.array([[[1]]]))
Ejemplo n.º 3
0
def test_single_value_in_domain_discrete_parameter():
    param = DiscreteParameter('x', [0, 1, 2])
    assert param.check_in_domain(0) is True
    assert param.check_in_domain(3) is False
Ejemplo n.º 4
0
def test_single_value_in_domain_discrete_parameter():
    param = DiscreteParameter('x', [0, 1, 2])
    assert param.check_in_domain(0) is True
    assert param.check_in_domain(3) is False
Ejemplo n.º 5
0
def test_discrete_parameter():
    param = DiscreteParameter('x', [0, 1, 2])
    assert param.name == 'x'
    assert param.check_in_domain(np.array([0, 1])) is True
    assert param.check_in_domain(np.array([3])) is False