def test_straightforward(self): x, y, z = floats("xyz") e = mul(add(x, y), true_div(x, y)) C = Composite([x, y], [e]) c = C.make_node(x, y) # print c.c_code(['x', 'y'], ['z'], dict(id = 0)) g = FunctionGraph([x, y], [c.out]) fn = DualLinker().accept(g).make_function() assert fn(1.0, 2.0) == 1.5
def test_with_constants(self): x, y, z = floats("xyz") e = mul(add(70.0, y), true_div(x, y)) C = Composite([x, y], [e]) c = C.make_node(x, y) assert "70.0" in c.op.c_code(c, "dummy", ["x", "y"], ["z"], dict(id=0)) # print c.c_code(['x', 'y'], ['z'], dict(id = 0)) g = FunctionGraph([x, y], [c.out]) fn = DualLinker().accept(g).make_function() assert fn(1.0, 2.0) == 36.0
def test_mul_add_true(): x, y, z = floats("xyz") e = mul(add(x, y), true_div(x, y)) g = FunctionGraph([x, y], [e]) fn = DualLinker().accept(g).make_function() assert fn(1.0, 2.0) == 1.5