Hello,

I am sorry if this is obvious, but I find myself stuck in
understanding some odd behavior of sympy.lambdify.

The problem is that, if I pass a dictionary, and a module, as a
namespace, to sympy lambdify, then I can apparently overwrite the
namespace of a function that has already been instantiated.     I
realize that's not very clear, but I hope this script helps to
explain:

n1 = {'f': lambda x:'first f',
      'g': lambda x:'first g'}
n2 = {'f': lambda x:'second f',
      'g': lambda x:'second g'}

f = sympy.Function('f')
g = sympy.Function('g')
x = sympy.Symbol('x')

if1 = sympy.lambdify(x, f(x), modules=(n1, "sympy"))
print 'f(x) before dict, string;', if1(1)
if2 = sympy.lambdify(x, g(x), modules=(n2, "sympy"))
print 'f(x) after dict, string;', if1(1)

- gives this output:

f(x) before dict, string; first f
f(x) after dict, string; second f

- meaning that the original generated lambda changes as a result of a
second call to lambdify.

The attached script shows that this occurs only when the first and
second calls have a dictionary and some other type of namespace.

I am sure that this is caused by some python thing I don't understand,
but I would be very grateful for any insight...

Thanks a lot,

Matthew

-- 
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.

Attachment: test_a2.py
Description: Binary data

Reply via email to