Stefan,

Thanks for the explanation on the first item.  My second item was typed in 
error ( and somehow the corrected post has not showed up yet). So, let me 
elaborate on the second issue.

I have a t1 = Tr(A*B*C),  and I set A,B,C = symbols('A B C', 
commutative=False).

Now, I have a method where I let the user do a cyclic permute on t1's 
arguments using t1.permute(1). This permute method returns t2 = Tr(C*A*B). 
 So far everything works fine. Until, this point I have not overridden the 
_hashable_content() method.


Now, I need to override my _hashable_contents() method so that I always 
return args  'A,B,C' ( in that order),  so that t1==t2 evaluates to True 
 (cycle property of trace).

But, once I implemented the _hashable_contents() method,  id(t2) is always 
equal to id(t1).  Which means I am not able to return Tr(C*A*B) when I call 
the permute method.


Makes sense?

Thanks
Guru
















On Friday, June 22, 2012 3:22:46 PM UTC-5, Stefan Krastanov wrote:
>
> On 22 June 2012 22:13, Guru Devanla <[email protected]> wrote: 
> > Hello All, 
> > 
> > Can someone explain why 2 objects in the following statements give me 
> the 
> > same id() value? 
> > 
> > 
> >>>> A, B = symbols('A B', commutative=False) 
> >>>> x = A*B 
> >>>> print id(x) 
> > 169853492 
> >>>> y = A*B 
> >>>> print id(y) 
> > 169853492 
>
> Because these are the same object A*B. x and y are just labels 
> pointing to an instance. 
>
> > 
> > I run into this problem while trying to implement some operation on 
> Trace 
> > module. 
> > 
> > Say, I have  Tr(A*B*C) . Now, the user wants to create another instance 
> of 
> > Tr(C*A*B).   But, both objects are getting the same id, meaning I am not 
> > able to create 2 different objects one which prints at Tr(A*B*C) and 
> another 
> > which prints as Tr(C*A*B).  Note, that I have not yet overridden 
> >  _hashable_contents to compare the args ( using the  cyclic property of 
> > trace). 
> > 
> Stupid question: Did you correctly set commutable=False for A,B and C. 
> Does Tr somehow override them? 
>
> > Am I missing something basic?   Or is there a way to override this 
> >  behavior, if necessary 
> > 
> > Thanks 
> > Guru 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > 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/-/lFlq7OJjqlkJ. 
> > 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. 
>

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

Reply via email to