logo       

[sage-devel] Re: buglet in maxima list: msg#01621

Subject: [sage-devel] Re: buglet in maxima list
On 5/5/07, Michel <michel.vandenbergh@xxxxxxxxxxx> wrote:
>
> I discovered a small bug in sage 2.4.2 in the handling of maxima
> lists.
> When iterating over a maxima list there is an off by one error.
> Individual
> item access works fine.

That's a bug.  I've fixed it for sage-2.5 by putting a correct __iter__ in
maxima.py.
>
> I think the bug is actually in the implementation of
> ExpectElement.__iter__
> which strangely starts iterating from 1!

That's because almost all math software that SAGE interfaces with
has 1-based indexing of lists.  In most cases the SAGE interface
respects this, e.g., in PARI:

sage: v = gp('[5,8*a,b^2]')
sage: v[1]
5
sage: v[2]
8*a
sage: w = list(v)
sage: w[0]
5
sage: w[1]
8*a
sage: type(v)
<class 'sage.interfaces.gp.GpElement'>
sage: type(w)
<type 'list'>


For some reason I can't remember the maxima interfaces uses 0-based
indexing instead of 1-based indexing (which is what maxima uses).

This inconsistency isn't a bug, since it's clearly documented in the
maxima interface.  However it is confusing. I should either change the
maxima indexing to be 1-based again (like Maxima's native indexing),
or change the other interfaces (to MAGMA, PARI, Mathematica) to
all be 0-based.  I'll wait for comments from people reading this before
deciding.

sage: magma([5,7])[1]               # good or bad?
5

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to 
sage-devel-unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---




<Prev in Thread] Current Thread [Next in Thread>