Status: Accepted
Owner: asmeurer
Labels: Type-Defect Priority-High Milestone-Release0.7.0

New issue 2070 by asmeurer: All elements of .args should be Basic
http://code.google.com/p/sympy/issues/detail?id=2070

There are two invariants that any .args attribute should uphold. The first is that Object.__class__(*Object.args) == Object, i.e., you should be able to rebuild the object exactly by calling it with its .args. Actually, strictly speaking, it should really be Object.__class__(*Object.args, **Object.kwargs), where kwargs is assumptions or options or something. We actually still need to fix that up once we completely dump the old assumptions.

But other than that, the first invariant holds pretty well among Basic objects in SymPy (except for maybe issue 1206). The second invariant is the one that is often violated. It is that all(isinstance(Basic.args, Basic)) == True should hold, i.e., every element of .args should itself be a instance of Basic. This is so it will be easy to recurse through .args, because every element of .args will itself have a .args.

Currently, many classes use tuples in their .args, violating this rule, and creating headaches like issue 2068. I know that Integral and Sum are two. There might also be others. The fix is to use the new Tuple container, which acts like a tuple but is also an element of Basic, so it works with .args.

*Note* .args itself should remain a tuple. Only the elements need to be fixed.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-iss...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to