I see both problems as somewhat artificial:

- We are forcing some kind of sorting on a mathematical concept that
does not depend on sorting only for the sake of doctests. The problem
is the way the doctest is written, not that FiniteSet orders its
elements (sorting for the sake of equality tests is different, and
being machine dependence is not a problem there).

- Permitting only Basic instances in args causes much pain: Symbol,
for instance, does not contain its name in its args. Every time that
we want to have a named object we jump trough hoops. This breaks
obj.func(*obj.args)==obj. There is no clear notion of atomic object in
sympy: some of the tree traversal algorithms check for empty args,
other for subclasses of Atom, etc.

The only argument that I have seen in favor of demanding only Basic in
args is for ease tree traversal. But if we set up sane rules and we
stick to them this would be completely unnecessary. For instance

def is_atom(a):
    if not isinstance(a, Basic):
        return True
    elif not a.args:
        return True
    else:
        return False

Or even better with a try except block as this will permit rebuilding
objects that do not subclass Basic but that have args interface:

def is_atom(a):
    try:
        if a.args:
            return False
        else:
            return True
    except AttributeError:
        return True

My argument *against* demanding only Basic in args is that this breaks
obj.func(*obj.args)==obj

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

Reply via email to