On Saturday, March 29, 2014 3:34:47 AM UTC+1, Aaron Meurer wrote: > > On Fri, Mar 28, 2014 at 9:13 PM, Stefan Krastanov > <stefan.k...@yale.edu <javascript:>> wrote: > >> Stefan, can you give a brief explanation of your experience? In > particular > >> what difficulties did you run into? > > > > The current tensor canonicalization and representation for tensors > > does not adhere to most of sympy's class invariants. > > > > - eq is occasionally about mathematical equality, not structural one, > > and it is even raising errors in some cases, which break dictionary > > lookups and so on > > > > - you can not recreate objects using func and args > > > > - substitution does not work (nothing related to tree traversal works > actually) > > > > - many others in the same style > > > > In one sentence: the implemented algorithms are very smart, but they > > completely disregard the invariants that sympy uses to work with the > > symbolic trees. > > > > I tried to go step by step and reinstate these invariants, but my > > knowledge of the module was insufficient. (actually, going in the > > other direction might be easier: the module when I was looking at it > > was not using any of sympy's methods, so it was not really necessary > > to subclass Basic or Expr). > > If you're using .args you might as well subclass from Basic, because > you get a bunch of useful methods like xreplace, __eq__, and __hash__ > for free. There are maybe still some methods on Basic that don't > belong there, but we should just work on moving them out. >
Currently, __eq__ and __hash__ are overwritten, in order to make the == operator correspond the tha mathematical equality. I see this is not standard in SymPy, since math equality is expressed by Eq( , ) , hope this won't cause much trouble to unify/rewriterule, otherwise the == behavior will have to be changed as well. > And if you're not using .args then you don't adhere to the basic > invariants of SymPy. > This issue has already been solved. -- 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 sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/9e5ecc88-ec0e-4e75-87ea-ed9e42753c69%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.