Ticket #9663: trac_9663-additional_tests.patch

File trac_9663-additional_tests.patch, 2.0 KB (added by ncohen, 9 years ago)
  • sage/combinat/combinat.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1283699944 -7200
    # Node ID ba80e016356f33c12b6d89fcaec97cb604c55a24
    # Parent  5606ff4160beed941caabfeb4a0a6e48b98bf021
    trac 9663 - short additional tests on stirling_number2
    
    diff -r 5606ff4160be -r ba80e016356f sage/combinat/combinat.py
    a b  
    642642        sage: type(n)
    643643        <type 'sage.rings.integer.Integer'>
    644644
     645     Sage's implementation splitting the computation of the Stirling
     646     numbers of the second kind in two cases according to `n`, let us
     647     check the result it gives agree with both maxima and gap.
     648
     649     For `n<200`::
     650
     651         sage: for n in Subsets(range(100,200), 5).random_element():
     652         ...      for k in Subsets(range(n), 5).random_element():
     653         ...         s_sage = stirling_number2(n,k)
     654         ...         s_maxima = stirling_number2(n,k, algorithm = "maxima")
     655         ...         s_gap = stirling_number2(n,k, algorithm = "gap")
     656         ...         if not (s_sage == s_maxima and s_sage == s_gap):
     657         ...             print "Error with n<200"
     658
     659     For `n\geq 200`::
     660
     661         sage: for n in Subsets(range(200,300), 5).random_element():
     662         ...      for k in Subsets(range(n), 5).random_element():
     663         ...         s_sage = stirling_number2(n,k)
     664         ...         s_maxima = stirling_number2(n,k, algorithm = "maxima")
     665         ...         s_gap = stirling_number2(n,k, algorithm = "gap")
     666         ...         if not (s_sage == s_maxima and s_sage == s_gap):
     667         ...             print "Error with n<200"
     668
     669
     670     TESTS:
     671
     672     Checking an exception is raised whenever a wrong value is given
     673     for ``algorithm``::
     674
     675         sage: s_sage = stirling_number2(50,3, algorithm = "CloudReading")
     676         Traceback (most recent call last):
     677         ...
     678         ValueError: unknown algorithm: CloudReading
    645679     """
    646680    if algorithm is None:
    647681        return _stirling_number2(n, k)