Exemple #1
0
 def test_gt(self):
     x, y, z = floats("xyz")
     fn = DualLinker().accept(FunctionGraph([x, y],
                                            [x > y])).make_function()
     for a, b in ((3.0, 9), (3, 0.9), (3, 3)):
         assert fn(a, b) == (a > b)
import pytest

import aesara

sympy = pytest.importorskip("sympy")

from aesara.scalar.basic import floats
from aesara.scalar.basic_sympy import SymPyCCode

xs = sympy.Symbol("x")
ys = sympy.Symbol("y")

xt, yt = floats("xy")


@pytest.mark.skipif(not aesara.config.cxx, reason="Need cxx for this test")
def test_SymPyCCode():
    op = SymPyCCode([xs, ys], xs + ys)
    e = op(xt, yt)
    g = aesara.gof.FunctionGraph([xt, yt], [e])
    fn = aesara.gof.CLinker().accept(g).make_function()
    assert fn(1.0, 2.0) == 3.0


def test_grad():
    op = SymPyCCode([xs], xs**2)
    zt = op(xt)
    ztprime = aesara.grad(zt, xt)
    assert ztprime.owner.op.expr == 2 * xs

Exemple #3
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
 def test_neq(self):
     x, y, z = floats("xyz")
     fn = gof.DualLinker().accept(FunctionGraph(
         [x, y], [neq(x, y)])).make_function()
     for a, b in ((3.0, 9), (3, 0.9), (3, 3)):
         assert fn(a, b) == (a != b)