Ondrej, Yes, the relativity.py example works. However, I want to do indicial tensor algebra and was hoping tensor.py is a start in that direction. The tensor.py included with the dist sympy-0.6.3 in examples is what I hacked. I don't see a way to attach a file in posting. I would have attached tensor.py if I had known how to do it. Want me to include it? The hacked version I used is what I included in my previous message. So you could just copy/paste that and get the result I got, presumably.
I am not sure I understand how the classes you devised for tensor.py work. They in fact do not quite work or else I have made some error in using/hacking. Please explain for the unwashed what you are doing in these class defs so I can unerringly get my understanding in sync with yours. Thanks. Comer On Mar 21, 7:38 pm, Ondrej Certik <[email protected]> wrote: > On Sat, Mar 21, 2009 at 2:04 PM, [email protected] > > <[email protected]> wrote: > > > Ondrej, > > > I have taken the tensor.py script and have stripped out most of it, > > wanting to see just how far it gets before crashing. Here is what I > > have: > > Which tensor.py have you taken? > > > > > > > from sympy import exp, Symbol, sin, Rational, Derivative, dsolve > > > from sympy.core import Basic, Function > > from sympy.matrices import Matrix > > > class Indexed(Basic): > > def __init__(self, A, idxlist): > > self._args = [A, idxlist] > > > def __str__(self): > > r = str(self[0]) > > for idx in self[1]: > > r+=str(idx) > > return r > > > class Idx(Symbol): > > def __init__(self, name, dim = 4, up = True): > > Symbol.__init__(self, name) > > #self._args.extend([dim,up]) > > self._name = name > > self._dim = dim > > self._up = up > > > def __str__(self): > > if self._up: > > r = "^" > > else: > > r = "_" > > return r+self._name > > > �...@property > > def up(self): > > return Idx(self._name, self._dim, True) > > > �...@property > > def dn(self): > > return Idx(self._name, self._dim, False) > > > def values(self): > > return range(self._dim) > > > mu = Idx("mu") > > nu = Idx("nu") <<====== by the way this was "mu" in the orginal,so I > > changed it. > > i = Idx("i") > > m = Idx("m") > > k = Idx("k") > > l = Idx("l") > > g = Indexed(Symbol("A"), [mu,nu]) > > > print g[i.up,m.up] > > #print g > > > As you can see I deleted the schwarzschild metric stuff as I am only > > interested in the indicial performance. This did not illuminate > > anything really. Here is what I get when I run it: > > > debian:~/sympy-0.6.3> python examples/indexed.py > > Traceback (most recent call last): > > File "examples/indexed.py", line 62, in ? > > print g[i.up,m.up] > > TypeError: unsubscriptable object > > > I am hoping to see > > > im > > g > > > although I did not use pprint.., > > > In any event, can you please explain a bit more about what you would > > expect this example to produce? > > I don't know which example you mean. the relativity.py example works fine. > > Ondrej --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
