Hi, I'm trying to get lambdify to take a vector as input so that I can
have a function G(x) where x is a vector. (The ultimate aim is to
evaluate linearizations at certain locations where the linearized
function is defined as a sympy Matrix.) Attempting to modify
sympy/test_external/test_numpy.py to include the test case results in
the traceback below. Should I expect this to work? If so, what am I
doing wrong?
def test_lambdify_matrix_vec_input():
x,y,z=sympy.symbols('xyz')
X=sympy.Matrix([x,y,z]) # our input vector
M=sympy.Matrix([[X[0]**2, x[0]*X[1], X[0]*X[2]],
[X[1]*X[0], X[1]**2, X[1]*X[2]],
[X[2]*X[0], X[2]*X[1], X[2]**2]])
f = lambdify(X, M, "numpy")
Xh = array([1.0, 2.0, 3.0])
expected = matrix([[Xh[0]**2, Xh[0]*Xh[1], Xh[0]*Xh[2]],
[Xh[1]*Xh[0], Xh[1]**2, Xh[1]*Xh[2]],
[Xh[2]*Xh[0], Xh[2]*Xh[1], Xh[2]**2]])
actual = f(Xh)
assert numpy.allclose(actual,expected)
Traceback (most recent call last):
File
"/home/astraw/PY/lib/python2.5/site-packages/nose-0.10.4-py2.5.egg/nose/case.py",
line 182, in runTest
self.test(*self.arg)
File
"/home/astraw/other-peoples-src/sympy/sympy.git/sympy/test_external/test_numpy.py",
line 225, in test_lambdify_matrix_vec_input
M=sympy.Matrix([[X[0]**2, x[0]*X[1], X[0]*X[2]],
TypeError: 'Symbol' object is unindexable
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---