Ticket #10025: trac_10025-smallfixes.patch

File trac_10025-smallfixes.patch, 4.7 KB (added by ncohen, 9 years ago)
• sage/combinat/sloane_functions.py

```# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1287930693 -7200
# Node ID 3832e843cc5df6e99984bfe57c29a8b91f081043
# Parent  e894562da4d58ab43dcb43ba007c87453252ca9d
trac 10025 -- some docstring/doctests problems in sloane.A109814

diff -r e894562da4d5 -r 3832e843cc5d sage/combinat/sloane_functions.py```
 a We agree with the online database:: sage: for t in sloane.trait_names(): # long time optional, requires internet ...       print t ...       online_list = sloane_sequence(ZZ(t[1:].lstrip('0')))[2] ...       online_list = sloane_sequence(ZZ(t[1:].lstrip('0')), verbose = False)[2] ...       L = max(2, len(online_list) // 2) ...       sage_list = sloane.__getattribute__(t).list(L) ...       if online_list[:L] != sage_list: return perm_mh(n, 4) class A109814(SloaneSequence): def __init__(self): r""" The `n`th term of the sequence `a(n)` is the largest `k` such that `n` can be written as sum of `k` consecutive integers. `n` is the sum of at most `a(n)` consecutive positive integers. Suppose `n` is to be written as sum of `k` consecutive integers starting with `m`, then `2n = k(2m + k - 1)`. Only one of the factors is odd. For each odd divisor `d` of `n` there is a unique corresponding `k = min(d,2n/d)`. `a(n)` is the largest among those `k` . See: http://www.jaapspies.nl/mathfiles/problem2005-2C.pdf INPUT: -  ``n`` - non negative integer OUTPUT: -  ``integer`` - function value r""" The `n` th term of the sequence `a(n)` is the largest `k` such that `n` can be written as sum of `k` consecutive integers. By definition, `n` is the sum of at most `a(n)` consecutive positive integers. Suppose `n` is to be written as sum of `k` consecutive integers starting with `m`, then `2n = k(2m + k - 1)`. Only one of the factors is odd. For each odd divisor `d` of `n` there is a unique corresponding `k = min(d,2n/d)`. `a(n)` can be alternatively defined as the largest among those `k` . .. SEEALSO:: * `Wikipedia article on polite numbers `_. * `An exercise sheet (with answers) about sums of consecutive integers `_. INPUT: -  ``n`` - non negative integer OUTPUT: -  ``integer`` - function value EXAMPLES:: sage: a = sloane.A109814; a a(n) is the largest k such that n can be written as sum of k consecutive positive integers. sage: a(0) Traceback (most recent call last): ... ValueError: input n (=0) must be a positive integer sage: a(2) 1 sage: a.list(9) [1, 1, 2, 1, 2, 3, 2, 1, 3] AUTHORS: - Jaap Spies (2007-01-13) """ def __init__(self): r""" EXAMPLES:: sage: a = sloane.A109814; a 1 sage: a.list(9) [1, 1, 2, 1, 2, 3, 2, 1, 3] AUTHORS: - Jaap Spies (2007-01-13) """ SloaneSequence.__init__(self, offset=1)
• sage/databases/sloane.py

`diff -r e894562da4d5 -r 3832e843cc5d sage/databases/sloane.py`
 a list = signed return [seqnum, description, [ZZ(n) for n in list]] def sloane_sequence(number): def sloane_sequence(number, verbose = True): """ Returns a list with the number, name, and values for the sequence ``number`` in Sloane's online database of integer sequences. INPUT: - ``number`` (integer) corresponding to the sequence. -  ``verbose`` - (boolean) print a string to let the user know that it is working and not hanging. Set to ``True`` by default. EXAMPLES:: number = str(ZZ(number)) except TypeError: raise TypeError, "input must be an integer or string that specifies the id of the Sloane sequence to download" results = sloane_find('id:A%s'%number) results = sloane_find('id:A%s'%number, verbose = verbose) if len(results) == 0: raise ValueError, "sequence '%s' not found"%number return results[0]