コード例 #1
0
def test_simple_calc():
    x1, x2 = Input(), Input()
    coef1, coef2 = Parameter(1), Parameter(3)
    func = Circuit([x1, x2], [x1 * coef1 + x2 * coef2])
    assert func([1, 1]) == [4]
    assert func([10, -1]) == [7]

    func_clone = func.clone()
    coef1.val = -1
    assert func([1, 1]) == [2]
    assert func([10, -1]) == [-13]

    assert func_clone([1, 1]) == [4]
    assert func_clone([10, -1]) == [7]