I seem to be making some progress but I still don’t have a working example. After reading some code, I found I could use the sympy function “aesara_code” in order to generate Aesara variables from sympy expressions:
import sympy
from aesara.tensor.var import TensorVariable
from sympy.printing.aesaracode import aesara_code, aesara_function
t = sympy.Symbol('t')
sympy_expr = t**2
aef = aesara_function([t], [sympy_expr])
def input(time):
if isinstance(time, TensorVariable):
return aesara_code(sympy_expr)
else:
return aef(time)
def freefall(y, t, p):
return 2.0 * p[1] - p[0] * y[0] + input(t)
I now actually provide a TensorVariable to PyMC when it expects one but I now get the error:
aesara.graph.utils.MissingInputError: Input 0 (t) of the graph (indices start from 0), used to compute Elemwise{pow,no_inplace}(t, TensorConstant{2}), was not provided and not given a value.
This happens in the codepath with the “aesara_code” call. The “return aef(time)” path works without issues.
It seems like the TensorVariable needs some additional initialization.