# 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 sage: type(n) Sage's implementation splitting the computation of the Stirling numbers of the second kind in two cases according to `n`, let us check the result it gives agree with both maxima and gap. For `n<200`:: sage: for n in Subsets(range(100,200), 5).random_element(): ...      for k in Subsets(range(n), 5).random_element(): ...         s_sage = stirling_number2(n,k) ...         s_maxima = stirling_number2(n,k, algorithm = "maxima") ...         s_gap = stirling_number2(n,k, algorithm = "gap") ...         if not (s_sage == s_maxima and s_sage == s_gap): ...             print "Error with n<200" For `n\geq 200`:: sage: for n in Subsets(range(200,300), 5).random_element(): ...      for k in Subsets(range(n), 5).random_element(): ...         s_sage = stirling_number2(n,k) ...         s_maxima = stirling_number2(n,k, algorithm = "maxima") ...         s_gap = stirling_number2(n,k, algorithm = "gap") ...         if not (s_sage == s_maxima and s_sage == s_gap): ...             print "Error with n<200" TESTS: Checking an exception is raised whenever a wrong value is given for ``algorithm``:: sage: s_sage = stirling_number2(50,3, algorithm = "CloudReading") Traceback (most recent call last): ... ValueError: unknown algorithm: CloudReading """ if algorithm is None: return _stirling_number2(n, k)