Message from discussion
subclassing from Symbol, only for the sake of having a name string
Received: by 10.224.76.205 with SMTP id d13mr2474821qak.3.1342986769101;
Sun, 22 Jul 2012 12:52:49 -0700 (PDT)
X-BeenThere: sympy@googlegroups.com
Received: by 10.224.98.8 with SMTP id o8ls5343379qan.3.gmail; Sun, 22 Jul 2012
12:52:48 -0700 (PDT)
Received: by 10.224.221.17 with SMTP id ia17mr7695191qab.2.1342986768018;
Sun, 22 Jul 2012 12:52:48 -0700 (PDT)
Received: by 10.224.221.17 with SMTP id ia17mr7695190qab.2.1342986768007;
Sun, 22 Jul 2012 12:52:48 -0700 (PDT)
Return-Path: <krastanov.ste...@gmail.com>
Received: from mail-qa0-f50.google.com (mail-qa0-f50.google.com [209.85.216.50])
by gmr-mx.google.com with ESMTPS id ft6si2087970qcb.0.2012.07.22.12.52.47
(version=TLSv1/SSLv3 cipher=OTHER);
Sun, 22 Jul 2012 12:52:48 -0700 (PDT)
Received-SPF: pass (google.com: domain of krastanov.ste...@gmail.com designates 209.85.216.50 as permitted sender) client-ip=209.85.216.50;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of krastanov.ste...@gmail.com designates 209.85.216.50 as permitted sender) smtp.mail=krastanov.ste...@gmail.com; dkim=pass header...@gmail.com
Received: by qafl39 with SMTP id l39so889136qaf.2
for <sympy@googlegroups.com>; Sun, 22 Jul 2012 12:52:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type;
bh=jNY0jWtHeyyWv6QEGgTcB/XFPaoYQWMI84kt0zhrhN8=;
b=yZvnyrI4oRaWoQZk1t/oO4TjRgVlnzNLWj2H9BcVTLMDp0mqwBnKEKiLILJlyE44Nu
D8ZvNZIGjjsmS9IA5yAJZ/9SUKbOyL9ASlfLWRsiMZuEifUIUGJjYT9t7DMP3siK198z
vta/RDBXRg1CN59uBFBAjePOOssQuNbthIScr/e7DVqlf6exQpw21TfuMfZC0bWrOhv3
nNVjUp3s6a1goCLZ3BLCb2sEuAs1XzNthcDVxn2K8DwSGeG8tsNGsA5AM/jRiEls4o/a
hXYUqPVlbKMdV5bi+wE9GlHzUrtzTXBL0LMuOAb0QueEer59L0yjR+WhrLiF7RhpYHBE
nlSw==
Received: by 10.224.176.69 with SMTP id bd5mr15801362qab.66.1342986767831;
Sun, 22 Jul 2012 12:52:47 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.229.238.15 with HTTP; Sun, 22 Jul 2012 12:52:27 -0700 (PDT)
In-Reply-To: <1342974925.2246.15.camel@ronan-desktop>
References: <CAD8szLwDK4P3SW58pY0yc6zapO8ytqP1+1p2B2qKqrM_SQs...@mail.gmail.com>
<CAD8szLxdNtKVDKcP7JznGMwGna9tJL-h8RzPr_OksZDFt2_...@mail.gmail.com>
<CAKgW=6J93qSMh_jmJ=aGVYH7OkZ5NM6UtdunmSkbE7AQJUi...@mail.gmail.com>
<1342926852.29300.15.camel@ronan-desktop> <CAD8szLxVww4OLXvO6N_pYRfZ1fB-ZPhi+JW68yRpX=5M4Ps...@mail.gmail.com>
<1342974925.2246.15.camel@ronan-desktop>
From: "krastanov.ste...@gmail.com" <krastanov.ste...@gmail.com>
Date: Sun, 22 Jul 2012 21:52:27 +0200
Message-ID: <CAD8szLxkuKeVHoGmM914XR2K1OBVEwwp6y_m4Q6bJW+eDQB...@mail.gmail.com>
Subject: Re: [sympy] Re: subclassing from Symbol, only for the sake of having
a name string
To: sympy@googlegroups.com
Content-Type: text/plain; charset=UTF-8
> Symbol is perfectly consistent with sympy's existing object model. Since
> it's an Atom, it doesn't have args and is free to use whatever
> attributes it needs.
>
> OTOH, what MatrixSymbol does is wrong and unsupported. Being an Atom and
> having args is inconsistent and causes problems for algorithms that
> don't expect it, eg.:
If it is still unclear, I am not stating that everything is ok as it
is. I am asking how to solve issues raised by objects like
MatrixSymbol. Just stating that it is not working with current
algorithms is not of much help.
>> So basically my question is. what do you prefer. Hacks like what is
>> done to the name string of Symbol or permitting non-Basic objects in
>> the args of the leafs of the sympy expression tree. Basically, the
>> presence of non-Basic objects in the args will be what defines the end
>> of the recursion.
>
> By definition, a leaf can't have args, so I don't understand what you
> mean. If you're saying that leaves should be either Atoms or non-Basic
> objects, that's de facto the way it works now, though making it the rule
> would contradict issue 2070 and test_args.py.
Well, this definition does not work well **in practice** at the
moment. This is why I am asking how to fix it. If neither using Symbol
for strings (hackish) nor redefining what an atom is (takes long time,
requires fixing many tree traversal routines) is a viable route
forward there must be another way.
I do not think that just stating "MatrixSymbols (or something similar)
has unexpected args" is of any help. No one has proposed a clear
solution that will work with "named object that must have args"
different from the two that have been proposed above.
So the way forward is to choose between (I may be missing alternative options):
- say that sympy will never support "named objects that must have args"
- use Symbol when we need name strings
- redefine what an atom is and correct each failing algorithm one by one
The first one is just giving up on implementing something that is
obviously useful.
The second one is hackish.
The third one is hard. However it would permit to refactor all three
traversal algorithms in a better abstracted way. Yes, it does
contradict issue 2070, but the only reason that this issue exists is
that the current methods for three traversal are limited (I may be
wrong about this, however I have asked the question many times and I
have never received a different answer.)