#16913: Error in prev()
-------------------------------------+-------------------------------------
       Reporter:  ayyer              |        Owner:
           Type:  defect             |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.4
      Component:  combinatorics      |   Resolution:
       Keywords:  permutations,      |    Merged in:
  prev                               |    Reviewers:
        Authors:  André Apitzsch     |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  a2406cd669acf5af044738f24c711b1f5526f3a5
  u/aapitzsch/ticket/16913           |     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------

Comment (by tscrim):

 Replying to [comment:2 vdelecroix]:
 > One line modification!! great!
 >
 > - What about `range(n-2,-1,-1)` instead of `reversed(range(0,n-1))`?

 +1 as when we switch to python3, the former should be faster (it should be
 a hair faster right now anyways).

 > - I really would like to see random tests that would prevent this kind
 of things happening again
 > {{{
 > sage: for _ in range(20):
 > ....:     p = Permutations(randint(2,10)).random_element()
 > ....:     assert p.next().prev() == p, "problem with p={}".format(p)
 > ....:     assert p.prev().next() == p, "problem with p={}".format(p)
 > }}}

 I don't like randomized testing, as errors may not be noticed from the
 testing. So a feature gets into Sage which then causes (random) doctest
 failures on a clean build. I think a more systematic test (especially in
 this case for some small values of n) is better. Yet I do think a larger
 test is better to have.

--
Ticket URL: <http://trac.sagemath.org/ticket/16913#comment:3>
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