#13516: prime_powers doesn't work with start very well
---------------------------------+------------------------------------------
Reporter: kcrisman | Owner: was
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.6
Component: number theory | Resolution:
Keywords: beginner | Work issues:
Report Upstream: N/A | Reviewers: Punarbasu Purkayastha
Authors: Kevin Halasz | Merged in:
Dependencies: | Stopgaps:
---------------------------------+------------------------------------------
Changes (by ppurka):
* reviewer: => Punarbasu Purkayastha
Old description:
> See [https://groups.google.com/forum/?fromgroups=#!topic/sage-
> support/lW_a7ZE3Zf8 this sage-support thread].
>
> {{{
>
> In Sage 5.3, the function prime_powers behaves a little strange:
>
> sage: prime_powers(4,10)
> [4, 5, 7, 8, 9]
> # As expected
>
> sage: prime_powers(5,10)
> [7, 8, 9]
> # 5 isn't a prime power anymore???
>
> # And now things become even worse:
> sage: prime_powers(7,10)
> ---------------------------------------------------------------------------
> IndexError Traceback (most recent call
> last)
>
> /home/mueller/<ipython console> in <module>()
>
> /home/mueller/local/sage-5.3/local/lib/python2.7/site-
> packages/sage/rings/arith.pyc in prime_powers(start, stop)
> 743 i = bisect(v, start)
> 744 if start > 2:
> --> 745 if v[i] == start:
> 746 i -= 1
> 747 w = list(v[i:])
>
> IndexError: list index out of range
> }}}
> Yeah, this seems problematic. The code in question is ''old'', too, so
> perhaps there is a more efficient way to do it in the meantime...
>
> '''Apply'''
>
> 1. [http://trac.sagemath.org/sage_trac/raw-
> attachment/ticket/13516/13516_primepowers.patch patch]
New description:
See [https://groups.google.com/forum/?fromgroups=#!topic/sage-
support/lW_a7ZE3Zf8 this sage-support thread].
{{{
In Sage 5.3, the function prime_powers behaves a little strange:
sage: prime_powers(4,10)
[4, 5, 7, 8, 9]
# As expected
sage: prime_powers(5,10)
[7, 8, 9]
# 5 isn't a prime power anymore???
# And now things become even worse:
sage: prime_powers(7,10)
---------------------------------------------------------------------------
IndexError Traceback (most recent call
last)
/home/mueller/<ipython console> in <module>()
/home/mueller/local/sage-5.3/local/lib/python2.7/site-
packages/sage/rings/arith.pyc in prime_powers(start, stop)
743 i = bisect(v, start)
744 if start > 2:
--> 745 if v[i] == start:
746 i -= 1
747 w = list(v[i:])
IndexError: list index out of range
}}}
Yeah, this seems problematic. The code in question is ''old'', too, so
perhaps there is a more efficient way to do it in the meantime...
'''Apply''' to `devel/sage`: [attachment:13516_reviewer.2.patch].
--
Comment:
Thanks a lot for addressing my concerns. I have made some changes to your
patch.
1. Fixed trailing whitespaces.
2. Made sure `prime_powers(-1, positive integer)` works.
3. Fixed `TypeError`.
The changes can be seen in [attachment:13516_reviewer.patch]. All these
changes have been merged with your patch and the new patch is now
[attachment:13516_reviewer.2.patch].
Aside from the above corrections, the changes introduced by your patch has
positive review from my side. If you think my changes are ok, feel free to
change the ticket to positive review.
Patchbot: apply 13516_reviewer.2.patch
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13516#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 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/sage-trac?hl=en.