I ended up making a shim between the two.
from numpy import *
from sympy import *
x = array([(1.1, 2.2), (3.3, 4.4), (5.5, 6.6)], dtype=[('s0', 'f8'),
('s1', 'f8')])
eq = 2.0 * Symbol('s0') - sqrt(Symbol('s1'))
from collections import Mapping
class FilterNdarray(Mapping):
def
I figured out the problem. It's in evalf_symbol.
def evalf_symbol(x, prec, options):
val = options['subs'][x]
The x is the actual symbol and the numpy array provided is indexed by the
string representation of the symbol.
Numpy can't index by a Symbol, ugh.
In [23]: x = array([(1.1,
Thanks Aaron, I'll follow that. However, that simple patch didn't work. It
causes more problems up the evaluation stack for sympy. I'm going to see if
I can monkey patch the numpy object, and if that works.
Shawn
--
You received this message because you are subscribed to the Google Groups
Here's a simpler example:
from numpy import *
from sympy import *
x = array([(1.1, 2.2), (3.3, 4.4), (5.5, 6.6)], dtype=[('s0', 'f8'),
('s1', 'f8')])
eq = 2.0 * Symbol('s0') - Symbol('s1')
2.0*x['s0']-x['s1'] # Gives correct result at command prompt
eq.evalf(x) # Fails
The constraints are
I'm struggling with the most direct route to use a time series numpy array
to get a time series back from a SymPy equation.
Ideally I'd like to call something like sol.evalf(x), but that doesn't
work. I have a loop structure that does it at present, but the continual
reconstructing a dict
On Wednesday, June 12, 2013 4:54:21 PM UTC-5, Aaron Meurer wrote:
Use lambdify().
I've just spent a couple hours fiddling with lambdify(). I can't seem to
get it to work. First of all, lambdify requires that one specify the args
for the first argument. I'm trying to write this to deal with