Open Peter230655 opened 15 hours ago
Here is a minimal reproducer of the issue:
import sympy as sm
import numpy as np
from opty.utils import ufuncify_matrix
x, y = sm.symbols("x y")
result, x_vals, y_vals = np.empty((1, 2)), np.array([1.0]), np.array([2.0])
expected = np.array([[1.0, 6.283185307179586]])
f_np = ufuncify_matrix((x, y), sm.Matrix([x, np.pi * y])) # works fine
f_np(result, x_vals, y_vals)
np.testing.assert_allclose(result, expected)
f_sm = ufuncify_matrix((x, y), sm.Matrix([x, sm.pi * y])) # crashes due to a compilation error
f_sm(x_vals, y_vals, result)
np.testing.assert_allclose(result, expected)
This morning I ran into a problem using opty for a simulation (Example 10.59 from Betts' book) With the help from @tjstienstra I found the problem was that I used sympy.pi in the equations of motion. Replacing it with numpy.pi solved the problem. Here I think, one can see that opty objects to sympy.pi:
in the simulation below, I added a factor sympy.cos(symypy.pi) / sympy.cos(numpy.pi) and sympy.pi / numpy.py, in lines 37, 38. For some reason, it accepts sympy.cos(sympy.pi), but not sympy.pi alone.
NB: