#18940: Polynomials ignore the step argument in __getitem__
-------------------------------------+-------------------------------------
       Reporter:  pbruin             |        Owner:
           Type:  defect             |       Status:  needs_info
       Priority:  major              |    Milestone:  sage-6.10
      Component:  algebra            |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Peter Bruin        |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/pbruin/18940-getitem_step        |  1c56779b3140d12fbe5d0973cdcad0ac9dbb8054
   Dependencies:  #19409             |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by tscrim):

 Replying to [comment:25 jdemeyer]:
 > Replying to [comment:24 tscrim]:
 > > That depends on if we want a slice of a polynomial returns a
 polynomial or a simple list of the coefficients. I am (very) slightly in
 favor of returning a polynomial, so with that `[0, 2, 4, 6, 8]`.
 >
 > Sorry, I asked a bad question so I cannot interpret your answer. Please
 try again with this question:
 > {{{
 > sage: pol = PolynomialRing(QQ, 'x')(range(1,10))
 > sage: list(pol[3::2])
 > }}}
 I would want this:
 {{{
 sage: list(pol[3::2])
 [0, 0, 0, 4, 6, 8]
 }}}
 (Actually, my answer above should have had 2 leading 0's: `[0, 0, 2, 4, 6,
 8]`.)

 However, when trying to think about how this would work for Laurent
 polynomials, we currently have this behavior for `list`:
 {{{
 sage: R.<x> = LaurentPolynomialRing(QQ)
 sage: p = ~x + 2 + 3*x + 4*x^2
 sage: list(p)
 [1, 2, 3, 4]
 sage: p = 3*x + 4*x^2
 sage: list(p)
 [3, 4]
 }}}
 In some ways I would say the iterator for polynomials should be changed to
 agree with that of Laurent polynomials, in that it starts from the lowest
 degree. Although I understand there are many (good) reasons why we do not
 want that behavior. I feel that at some point we just have to choose the
 least bad of all options and then put up warning messages about our
 choices.

--
Ticket URL: <http://trac.sagemath.org/ticket/18940#comment:26>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to