Exemplo n.º 1
0
def test_logical_model_variables_append_without_initialize(shape):
    model = LogicalModel(mtype="ising")
    # The following operation will be successful with a UserWarning.
    with pytest.warns(UserWarning):
        model.append("x", shape=shape)
    assert "x" in model.get_variables()
    assert model.get_variables_by_name("x").shape == shape
Exemplo n.º 2
0
def test_logical_model_variables_append(initial_shape, additional_shape, expected_shape):
    model = LogicalModel(mtype="ising")
    model.variables("x", shape=initial_shape)
    assert "x" in model.get_variables()
    assert model.get_variables_by_name("x").shape == initial_shape

    model.append("x", shape=additional_shape)
    assert model.get_variables_by_name("x").shape == expected_shape