I guess I didn't know what Atomic meant; thanks for pointing that out, it works fine now.
Sean On Thu, Jun 30, 2011 at 19:57, Ronan Lamy <[email protected]> wrote: > Le jeudi 30 juin 2011 à 19:12 -0500, Sean Vig a écrit : > > CG subclasses from AtomicExpr. > > Why did you choose that? "Atomic" means that it's not made up of other > sympy objects and that methods like .match() will therefore not recurse > inside your object. So if you can derive directly from Expr instead of > AtomicExpr, you should get the behaviour you want. > > > On Thu, Jun 30, 2011 at 18:50, Aaron Meurer <[email protected]> > > wrote: > > What does your CG subclass from? If it's a Function, I think > > it > > should automatically work, like > > > > In [50]: a = Wild('a') > > > > In [51]: f(1, 2).match(f(a, 2)) > > Out[51]: {a: 1} > > > > Aaron Meurer > > > > > > On Thu, Jun 30, 2011 at 3:04 PM, Sean Vig > > <[email protected]> wrote: > > > Hi everyone, > > > For a part of my project I tried using pattern matching > > with .match and > > > Wild, as described > > > > > here http://docs.sympy.org/0.7.0/tutorial.html#pattern-matching, > to match > > > some instances of a class I am working on, however it does > > not currently > > > work as I'd hoped in trying to match objects of CG, which > > subclasses Expr. > > > For example, I'd like to be able to get > > >>>> x = Wild('x') > > >>>> (CG(1,1,1,1,1,1)).match(CG(x,1,1,1,1,1) > > > {x: 1} > > > However it currently gives None. I assume I need to > > implement some function > > > (maybe matches or _matches), but if someone knows a bit more > > about pattern > > > matching that could advise me here, I'd appreciate it. > > Thanks. > > > Sean > > > > > > > > -- > > > 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. > > > > > > > -- > > 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 sympy > > [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 post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to sympy > > [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 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 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.
