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(Env([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(Env([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(Env([x, y, z], [e])) fn = lnk.make_function() if theano.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
def test_c_fail_error(): if not theano.config.cxx: pytest.skip("G++ not available, so we need to skip this test.") x, y, z = inputs() x = Constant(tdouble, 7.2, name="x") e = add_fail(mul(x, y), mul(y, z)) lnk = OpWiseCLinker().accept(Env([y, z], [e])) fn = lnk.make_function() with pytest.raises(RuntimeError): fn(1.5, 3.0)
def test_c_fail_error(): if not theano.config.cxx: raise SkipTest("G++ not available, so we need to skip this test.") x, y, z = inputs() x = Constant(tdouble, 7.2, name='x') e = add_fail(mul(x, y), mul(y, z)) lnk = OpWiseCLinker().accept(Env([y, z], [e])) fn = lnk.make_function() try: fn(1.5, 3.0) except RuntimeError: print('Yay, TEST PASSED') return # test passed assert 0 # test failed
def test_c_fail_error(): if not theano.config.cxx: raise SkipTest("G++ not available, so we need to skip this test.") x, y, z = inputs() x = Constant(tdouble, 7.2, name='x') e = add_fail(mul(x, y), mul(y, z)) lnk = OpWiseCLinker().accept(Env([y, z], [e])) fn = lnk.make_function() try: res = fn(1.5, 3.0) except RuntimeError: print 'Yay, TEST PASSED' return # test passed assert 0 # test failed