Prasoon, Is this from PR 2208? If so, it looks like the only ._args for a BaseScalar are the associated CoordSys and the position, and not the name itself. Obviously if they have the same position the second args will be equal. I bet if the CoordSys are evaluating as True, that is the cause of your problem. What is _args for each CoordSys in this case?
-Gilbert On Wed, Aug 28, 2013 at 9:47 AM, Aaron Meurer <[email protected]> wrote: > On Wed, Aug 28, 2013 at 7:29 AM, Prasoon Shukla > <[email protected]> wrote: > > I have ran into a caching problem while working on my project for the > vector > > calcculus module. This occurred while I was debugging the express method > on > > vector (this isn't really relevant though). > > > > So, I have a symbol theta and another symbol phi. > > > >>>> cs.theta > > cs.theta > > > >>>> cs.phi > > cs.phi > > > > cs is an instance of the CoordSysSph class (again, not really relevant to > > the problem at hand). > > > > The problem: > >>>> sin(cs.theta) * sin(cs.phi) > > sin(cs.theta) ** 2 > > > > Well, in the definition for the cacheit decorator, the dicitionary > > func_cache_it_cache exists. Now, when sin(cs.theta) is called, a key, > value > > pair gets added to the dictionary: > > > > ((sin, <class 'sympy.core.function.FunctionClass'>), (cs.theta, <class > > 'sympy.vector.vector.BaseScalar'>)) : sin(cs.theta) > > > > Now, when SymPy needs to calculate sin(cs.phi), the cacheit decorator is > > called again. The lookup key for sin(cs.phi) is generated as: > > ((sin, <class 'sympy.core.function.FunctionClass'>), (cs.phi, <class > > 'sympy.vector.vector.BaseScalar'>)) > > Oh, just noticed this. phi and theta are not Symbols, they are > BaseScalars. So you probably did something wrong implementing equality > comparison on BaseScalars. What does "cs.phi == cs.theta" give? > > Can you give a complete code snipped to reproduce this in your branch? > > Aaron Meurer > > > > > At this point, the func_cache_it_cache does not have the key > correspondind > > to sin(cs.phi), as it shouldn't. But, here's the catch: running the > has_key > > method on func_cache_it_cache for this second key (for sin(cs.phi)) > returns > > True. That means, the cache returns sin(cs.theta). And that is what is > > causing the problem. > > > > What can I possibly do here? For the time being, I am going to proceed > with > > the debugging. When there is a solution for this problem, we can go ahead > > and fix this. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "sympy" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to [email protected]. > > To post to this group, send email to [email protected]. > > Visit this group at http://groups.google.com/group/sympy. > > For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
