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,
https://github.com/sympy/sympy/wiki/development-workflow
Aaron Meurer
On Tue, Jun 25, 2013 at 9:16 AM, Shawn Garbett shawn.garb...@gmail.com wrote:
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
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
You can get all the variables in an expression using
expr.free_symbols. I hope that helps.
Aaron Meurer
On Mon, Jun 24, 2013 at 3:37 PM, Shawn Garbett shawn.garb...@gmail.com wrote:
Here's a simpler example:
from numpy import *
from sympy import *
x = array([(1.1, 2.2), (3.3, 4.4), (5.5,
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
Use lambdify().
Aaron Meurer
On Wed, Jun 12, 2013 at 1:06 PM, Shawn Garbett shawn.garb...@gmail.com wrote:
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
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
It may be that we don't understand your application given your example.
From your example I suspect you want to compute something like the
following
In [1]: from sympy import *
In [2]: s4 = Symbol('s4')
In [3]: s6 = Symbol('s6')
In [4]: sol = 1.0e-6*s4 + 1.0e-12*s6
In [5]: sol
Out[5]: 1.0e-6*s4
10 matches
Mail list logo