def test_opwiseclinker_constant(): x, y, z = inputs() x = Constant(tdouble, 7.2, name="x") e = add(mul(x, y), mul(y, z)) lnk = OpWiseCLinker().accept(FunctionGraph([y, z], [e])) fn = lnk.make_function() res = fn(1.5, 3.0) assert res == 15.3
def test_c_fail_error(): x, y, z = inputs() x = Constant(tdouble, 7.2, name="x") e = add_fail(mul(x, y), mul(y, z)) lnk = OpWiseCLinker().accept(FunctionGraph([y, z], [e])) fn = lnk.make_function() with pytest.raises(RuntimeError): fn(1.5, 3.0)
def test_opwiseclinker_straightforward(): x, y, z = inputs() e = add(mul(add(x, y), div(x, y)), bad_sub(bad_sub(x, y), z)) lnk = OpWiseCLinker().accept(FunctionGraph([x, y, z], [e])) fn = lnk.make_function() if aesara.config.cxx: assert fn(2.0, 2.0, 2.0) == 2.0 else: # The python version of bad_sub always return -10. assert fn(2.0, 2.0, 2.0) == -6