Add

0 views
Skip to first unread message

Neal Becker

unread,
Nov 13, 2009, 8:23:17 AM11/13/09
to sympy
What's the correct way to do this?

eq_coef = [(-0.0091917933841857494-9.7400455464966181e-05j), ...]

H_eq = Add ([eq_coef[k] * E**(-I*pi*k*v) for k in range (len (eq_coef))]) <<<
This gives an error unhashable type: 'list'


H_eq = Add (eq_coef[k] * E**(-I*pi*k*v) for k in range (len (eq_coef))) <<<
This gives a different error SympifyError: <generator object <genexpr> at
0x333b820> is NOT a valid SymPy expression

Ronan Lamy

unread,
Nov 13, 2009, 2:25:41 PM11/13/09
to sy...@googlegroups.com

H_eq = Add (*[eq_coef[k] * E**(-I*pi*k*v) for k in range (len
(eq_coef))])

Add doesn't accept sequences directly, you need to unpack them.

I guess this should go to a FAQ somewhere, if it's not there already.

Reply all
Reply to author
Forward
0 new messages