Ticket #10784 (closed enhancement: fixed)
primes can have better functionality.
| Reported by: | mderickx | Owned by: | was |
|---|---|---|---|
| Priority: | major | Milestone: | sage-4.7 |
| Component: | number theory | Keywords: | prime, iterator, beginner |
| Cc: | niles | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Karl-Dieter Crisman |
| Authors: | Douglas McNeil | Merged in: | sage-4.7.alpha2 |
| Dependencies: | Stopgaps: |
Description (last modified by jdemeyer) (diff)
In this topic: http://groups.google.com/group/sage-devel/browse_thread/thread/cd05585cf395b3a0/c7c82fbb725dee50
D.S. McNeil posted several ideas for enhancing sage. This ticket is for the enhancements proposed for the primes function.
(3) primes(10, infinity) should work. Since we're just calling next_prime, there's no reason to require the upper limit to be an integer. Wouldn't mind a proof=False option which calls next_probable_prime instead, either.
Apply trac_10784_primes_enhancements.patch and trac_10784-reviewer.patch
Attachments
Change History
comment:1 Changed 2 years ago by mderickx
- Owner changed from tbd to was
- Type changed from PLEASE CHANGE to enhancement
- Component changed from PLEASE CHANGE to number theory
- Milestone set to sage-4.7
Changed 2 years ago by dsm
-
attachment
trac_10784_primes_enhancements.patch
added
allow +infinity, proof
comment:2 Changed 2 years ago by dsm
Patch attached to allow support for infinity as upper bound and proof option (with same semantics as next_prime's proof option: it's simply passed through to next_prime).
First idea was to avoid casting to ZZ entirely, which would allow primes(2, 100/3), but that can lead to some mysterious error messages. Current approach simply special-cases infinity as an upper bound -- allowing -infinity as a lower bound isn't that useful, because unlike the case of an infinite upper bound, that can be easily worked around from outside the function, and so problems with the bounds are caught at first iteration, which seems better.
comment:3 Changed 2 years ago by dsm
- Summary changed from primes can have better functionallity. to primes can have better functionality.
comment:4 Changed 2 years ago by niles
- Cc niles added
- Keywords prime, iterator, beginner added
- Status changed from new to needs_review
- Description modified (diff)
- Authors set to D. S. McNeil
Looks really good -- I've marked it as 'beginner', meaning that this is a patch which someone who is just beginning could review. If no one beats me to it, I'll go ahead and review it :)
comment:5 Changed 2 years ago by kcrisman
- Status changed from needs_review to positive_review
- Reviewers set to Karl-Dieter Crisman
- Description modified (diff)
This is a great patch, nicely tested. I've made some minor tweaks in the documentation to remove some errors in the docbuild and a few other things like indentation, and added one doctest. Positive review.
Changed 2 years ago by kcrisman
-
attachment
trac_10784-reviewer.patch
added
Apply after initial patch
