You can try expect_obs = tt.as_tensor_variable(expect())
But since your function takes no input, I will advise you to compute the expect_obs within the model, and also vectorized the computation (for loop is usually inefficient):
with ...
...
# T with shape [a]
V_th = 8.61733e-5 * T
J0 = Bp * T ** (3 / n) * tt.exp(-1.2 / V_th / n)
# V with shape [b]
data = J0[..., None] * (tt.exp(V / V_th[..., None] / n) - 1)
# data with shape [a, b]
expect_obs = tt.flatten(data)
2 Likes