Verbatim, subscript and slices

24 views
Skip to first unread message

Damien

unread,
Oct 18, 2011, 10:17:16 AM10/18/11
to SympyCore
Hello all,

I'm thinking of using SympyCore as the basis for a project where I
would make extensive use of SLICE, SUBSCRIPT and ATTR heads within
expressions (including using symbolic expressions as indices), mostly
within the Verbatim algebra but occasionally converting fragments of
expressions to Calculus.

It seems that SLICE, SUBSCRIPT and ATTR heads are not currently used
much (except probably in the Matrix classes) and that there are a few
rough edges, for instance:

In [149]: Verbatim("a[3]").as_algebra(Verbatim)
NotImplementedError: SUBSCRIPT.walk(func, cls, data, target) method
Please report this issue to http://code.google.com/p/sympycore/issues/
.

So, I've implemented a walk() method for Subscript heads, but there
are further errors downstream. Is this just because these methods need
implementing, or am I trying to do things the wrong way?

One last question:

In [142]: Verbatim(3)
Out[142]: Verbatim(SYMBOL, 3)

In [145]: Verbatim("3")
Out[145]: Verbatim(NUMBER, 3)

Any reason the head is SYMBOL in the first case and not NUMBER?

Regards!

Pearu Peterson

unread,
Oct 18, 2011, 1:35:52 PM10/18/11
to symp...@googlegroups.com
Hi Damien,

On Tue, Oct 18, 2011 at 5:17 PM, Damien <damie...@gmail.com> wrote:
Hello all,

I'm thinking of using SympyCore as the basis for a project where I
would make extensive use of SLICE, SUBSCRIPT and ATTR heads within
expressions (including using symbolic expressions as indices), mostly
within the Verbatim algebra but occasionally converting fragments of
expressions to Calculus.

It seems that SLICE, SUBSCRIPT and ATTR heads are not currently used
much (except probably in the Matrix classes) and that there are a few
rough edges, for instance:

In [149]: Verbatim("a[3]").as_algebra(Verbatim)
NotImplementedError: SUBSCRIPT.walk(func, cls, data, target) method
 Please report this issue to http://code.google.com/p/sympycore/issues/
.

So, I've implemented a walk() method for Subscript heads,

Could you send a patch to sympycore issues?
 
but there are further errors downstream.

I would be interested in the details of these errors. Submitting the walk patch should be sufficient for me to study these errors further.
 
Is this just because these methods need
implementing, or am I trying to do things the wrong way?

One last question:

In [142]: Verbatim(3)
Out[142]: Verbatim(SYMBOL, 3)

In [145]: Verbatim("3")
Out[145]: Verbatim(NUMBER, 3)

Any reason the head is SYMBOL in the first case and not NUMBER?


No. If NUMBER head will be more useful then it should be implemented in Verbatim.convert class method.
Currently, the convert method handles strings, lists and tuples while for all other object types they are treated as SYMBOL-s.
Now, I just committed a patch that implements proper handling of number types and dict objects in Verbatim.convert.

Regards,
Pearu

Damien

unread,
Oct 20, 2011, 7:28:17 AM10/20/11
to SympyCore
Hi Pearu,

Thanks for the reply!

I have opened a new issue with the errors and patch:
http://code.google.com/p/sympycore/issues/detail?id=68

Regards,
Damien

On Oct 18, 7:35 pm, Pearu Peterson <pearu.peter...@gmail.com> wrote:
> Hi Damien,
>
>
>
>
>
> On Tue, Oct 18, 2011 at 5:17 PM, Damien <damien.d...@gmail.com> wrote:
> > Hello all,
>
> > I'm thinking of using SympyCore as the basis for a project where I
> > would make extensive use of SLICE, SUBSCRIPT and ATTR heads within
> > expressions (including using symbolic expressions as indices), mostly
> > within the Verbatim algebra but occasionally converting fragments of
> > expressions to Calculus.
>
> > It seems that SLICE, SUBSCRIPT and ATTR heads are not currently used
> > much (except probably in the Matrix classes) and that there are a few
> > rough edges, for instance:
>
> > In [149]: Verbatim("a[3]").as_algebra(Verbatim)
> > NotImplementedError: SUBSCRIPT.walk(func, cls, data, target) method
> >  Please report this issue tohttp://code.google.com/p/sympycore/issues/
Reply all
Reply to author
Forward
0 new messages