Hi ,
I am working with the tensor module of sympy (0.7.2) python (2.7.1) and I
am having troubles to replace correctly the tensor objects :
For instance if I have a tensor L :
L = IndexedBase('L')
and two indicies a,b:
a,b = map(Idx,['a','b'])
Now I construc the following expression :
exp = 2*L[a,b]
If I want to replace L[a,b] in my expression in a general way using
matching pattern ( I assuming there other terms ), I can do :
p,q = map(Wild,['p','q']
exp = exp.replace(L[p,q],p)
I got >> 2*a
The problem arise when I have one of the indices that has a definite value,
1 for instance. Let's assume I now have
exp = 2*L[1,0] and I still want to replace it
exp.replace(L[p,q],p)
would rise an error :
>>AttributeError: 'int' object has no attribute 'args'
In principle if I know what are the values (1 and 0) I can use subs
exp = exp.subs(L[1,0],1)
>>2
But I want to be able to use the matching and therefore subs does not work.
Does anyone knows how I could go around this ?
Thanks
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sympy/-/Won4heE3S2MJ.
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.