# Ticket #11115: trac_11115_docfix.patch

File trac_11115_docfix.patch, 25.4 KB (added by SimonKing, 9 years ago)

Fix some doc strings, and add the required blank line after embedding information for cached methods

• ## sage/algebras/iwahori_hecke_algebra.py

# HG changeset patch
# User Simon King <simon.king@uni-jena.de>
# Date 1319560425 -7200
# Node ID 814cb45375fbf7319081e445a736c516f9b7ae86
# Parent  93ca48b60ae5cd165b55e4c6be9b5d0e334d06d4
#11115: Fix some doc strings.
Add a blank line in the doc string of cached methods after the embedding information.
Make correct use of cached functions in sage/algebras/steenrod/steenrod_algebra_bases.py

diff --git a/sage/algebras/iwahori_hecke_algebra.py b/sage/algebras/iwahori_hecke_algebra.py
 a that case, the algebra generators are also invertible and this method returns their inverses. EXAMPLES :: EXAMPLES:: sage: P. = PolynomialRing(QQ) sage: F = Frac(P) sage: H = IwahoriHeckeAlgebraT("A2",q,base_ring=F)
• ## sage/algebras/quatalg/quaternion_algebra.py

diff --git a/sage/algebras/quatalg/quaternion_algebra.py b/sage/algebras/quatalg/quaternion_algebra.py
 a r""" Return mod p splitting data for this quaternion algebra at the unramified prime p.  This is 2\times 2 matrices I, J, K over the finite field \GF{p} such that if matrices I, J, K over the finite field \GF{p} such that if the quaternion algebra has generators i, j, k, then I^2 = i^2, J^2 = j^2, IJ=K and IJ=-JI. INPUT: - p -- prime number (see below) - p -- prime number (see below) - alpha -- (default: None) element of quaternion algebra, which can be used to parameterize the order of the ideals J.  More precisely the J's are the right annihilators of (1,0) \alpha^i for i=0,1,2,...,p - alpha -- (default: None) element of quaternion algebra, which can be used to parameterize the order of the ideals J.  More precisely the J's are the right annihilators of (1,0) \alpha^i for i=0,1,2,...,p OUTPUT: - list of right ideals - list of right ideals .. note::
• ## sage/algebras/steenrod/steenrod_algebra_bases.py

diff --git a/sage/algebras/steenrod/steenrod_algebra_bases.py b/sage/algebras/steenrod/steenrod_algebra_bases.py
 a - John H. Palmieri (2008-07-30): version 0.9 - John H. Palmieri (2010-06-30): version 1.0 - Simon King (2011-10-25): Fix the use of cached functions This package defines functions for computing various bases of the Steenrod algebra, and for converting between the Milnor basis and - :func:steenrod_algebra_basis.  This computes a tuple representing basis elements for the Steenrod algebra in a given degree, at a given prime, with respect to a given basis.  Note: the work is done by the function :func:steenrod_algebra_basis_ (note trailing underscore), while :func:steenrod_algebra_basis is just a version of this which automatically caches its results. given prime, with respect to a given basis. It is a cached function. - :func:convert_to_milnor_matrix.  This returns the change-of-basis matrix, in a given degree, from any basis to the Milnor basis.  As with the previous function, the work is actually done by :func:convert_to_milnor_matrix_, and then :func:convert_to_milnor_matrix is the cached version. matrix, in a given degree, from any basis to the Milnor basis. It is a cached function. - :func:convert_from_milnor_matrix.  This returns the inverse of the previous matrix. In this file :file:steenrod_algebra_bases.py: - add appropriate lines to :func:steenrod_algebra_basis_. - add appropriate lines to :func:steenrod_algebra_basis. - add a function to compute the basis in a given dimension (to be called by :func:steenrod_algebra_basis_). called by :func:steenrod_algebra_basis). - modify :func:steenrod_basis_error_check so it checks the new basis. #  Distributed under the terms of the GNU General Public License (GPL) #***************************************************************************** from sage.misc.cachefunc import CachedFunction from sage.misc.cachefunc import cached_function def convert_to_milnor_matrix_(n, basis, p=2): @cached_function def convert_to_milnor_matrix(n, basis, p=2): r""" Change-of-basis matrix, 'basis' to Milnor, in dimension n, at the prime p. INPUT: - n - non-negative integer, the dimension - basis - string, the basis from which to convert - p - positive prime number (optional, default 2) OUTPUT: matrix - change-of-basis matrix, a square matrix over GF(p) OUTPUT: matrix - change-of-basis matrix, a square matrix over GF(p) .. note:: d = len(milnor_base) return matrix(GF(p),d,d,rows) convert_to_milnor_matrix = CachedFunction(convert_to_milnor_matrix_) def convert_from_milnor_matrix(n, basis, p=2): r""" Change-of-basis matrix, Milnor to 'basis', in dimension else: return mat def steenrod_algebra_basis_(n, basis='milnor', p=2, **kwds): @cached_function def steenrod_algebra_basis(n, basis='milnor', p=2, **kwds): r""" Basis for the Steenrod algebra in degree n. INPUT: - n - non-negative integer - basis - string, which basis to use (optional, default = 'milnor') - basis - string, which basis to use (optional, default = 'milnor') - p - positive prime number (optional, default = 2) - profile - profile function (optional, default None).  This is just passed on to the functions :func:milnor_basis and :func:pst_basis. - truncation_type - truncation type, either 0 or Infinity (optional, default Infinity if no profile function is specified, 0 otherwise).  This is just passed on to the function :func:milnor_basis. OUTPUT: tuple of objects representing basis elements for the Steenrod algebra in dimension n OUTPUT: Tuple of objects representing basis elements for the Steenrod algebra in dimension n. .. note:: else: raise ValueError, "Unknown basis: %s at the prime %s" % (basis, p) steenrod_algebra_basis = CachedFunction(steenrod_algebra_basis_) # helper functions for producing bases def restricted_partitions(n, l, no_repeats=False): """ import sage.misc.misc as misc # Apparently, in this test function, we don't want to benefit from caching. # Hence, the uncached version of steenrod_algebra_basis and of # convert_to-milnor_matrix are used. if p == 2: bases = ('adem','woody', 'woodz', 'wall', 'arnona', 'arnonc', 'pst_rlex', 'pst_llex', 'pst_deg', 'pst_revz', for i in range(dim): if i % 5 == 0: misc.verbose("up to dimension %s"%i) milnor_dim = len(steenrod_algebra_basis_(i,'milnor',p=p)) milnor_dim = len(steenrod_algebra_basis.f(i,'milnor',p=p)) for B in bases: # use steenrod_algebra_basis_, the uncached version if milnor_dim != len(steenrod_algebra_basis_(i,B,p)): if milnor_dim != len(steenrod_algebra_basis.f(i,B,p)): print "problem with milnor/" + B + " in dimension ", i # use convert_to_milnor_matrix_, the uncached version mat = convert_to_milnor_matrix_(i,B,p) mat = convert_to_milnor_matrix.f(i,B,p) if mat.nrows() != 0 and not mat.is_invertible(): print "%s invertibility problem in dim %s at p=%s" % (B, i, p) if i % 5 == 0: misc.verbose("up to dimension %s"%i) for pro in profiles: milnor_dim = len(steenrod_algebra_basis_(i,'milnor',p=p,profile=pro)) milnor_dim = len(steenrod_algebra_basis.f(i,'milnor',p=p,profile=pro)) for B in bases: if milnor_dim != len(steenrod_algebra_basis_(i,B,p,profile=pro)): if milnor_dim != len(steenrod_algebra_basis.f(i,B,p,profile=pro)): print "problem with milnor/%s in dimension %s with profile %s"%(B, i, pro) misc.verbose("done checking with profiles")
• ## sage/algebras/steenrod/steenrod_algebra_mult.py

diff --git a/sage/algebras/steenrod/steenrod_algebra_mult.py b/sage/algebras/steenrod/steenrod_algebra_mult.py
 a multiplication. - John H. Palmieri (2010-06-30: version 1.0) multiplication of Serre-Cartan basis elements using the Adem relations. - Simon King (2011-10-25): Fix the use of cached functions. .. rubric:: Milnor multiplication, p=2 #  Distributed under the terms of the GNU General Public License (GPL) #***************************************************************************** from sage.misc.cachefunc import CachedFunction from sage.misc.cachefunc import cached_function # Milnor, p=2 - r - tuple of non-negative integers - s - tuple of non-negative integers OUTPUT: Dictionary of terms of the form (tuple: coeff), where OUTPUT: Dictionary of terms of the form (tuple: coeff), where 'tuple' is a tuple of non-negative integers and 'coeff' is 1. This computes Milnor matrices for the product of $\text{Sq}(r)$ - list - list of integers OUTPUT: None if the multinomial coefficient is 0, or sum of list if it is 1 OUTPUT: None if the multinomial coefficient is 0, or sum of list if it is 1 Given the input $[n_1, n_2, n_3, ...]$, this computes the multinomial coefficient $(n_1 + n_2 + n_3 + ...)! / (n_1! n_2! - m2 - pair of tuples (f,s), same format as m1 - p - odd prime number OUTPUT: Dictionary of terms of the form (tuple: coeff), where 'tuple' is a pair of tuples, as for r and s, and 'coeff' is an integer mod p. OUTPUT: Dictionary of terms of the form (tuple: coeff), where 'tuple' is a pair of tuples, as for r and s, and 'coeff' is an integer mod p. This computes the product of the Milnor basis elements$Q_{e_1} Q_{e_2} ... P(r_1, r_2, ...)$and - list - list of integers - p - a prime number OUTPUT: Associated multinomial coefficient, mod p OUTPUT: Associated multinomial coefficient, mod p Given the input$[n_1, n_2, n_3, ...]$, this computes the multinomial coefficient$(n_1 + n_2 + n_3 + ...)! / (n_1! n_2! - n, k - integers OUTPUT: n choose k, mod 2 OUTPUT: n choose k, mod 2 EXAMPLES:: - n, k - integers - p - prime number OUTPUT: n choose k, mod p OUTPUT: n choose k, mod p EXAMPLES:: return 0 return multinomial_odd([n-k, k], p) def adem_(a, b, c=0, p=2): @cached_function def adem(a, b, c=0, p=2): r""" The mod p Adem relations to either P^a P^b or (if c present) to P^a \beta^b P^c - p - positive prime number (optional, default 2) OUTPUT: a dictionary representing the mod p Adem relations OUTPUT: a dictionary representing the mod p Adem relations applied to P^a P^b or (if c present) to P^a \beta^b P^c. .. note:: result[(0,A+B-j,1,j,0)] = coeff return result adem = CachedFunction(adem_) def make_mono_admissible_(mono, p=2): @cached_function def make_mono_admissible(mono, p=2): r""" Given a tuple mono, view it as a product of Steenrod operations, and return a dictionary giving data equivalent to - mono - a tuple of non-negative integers - p - prime number, optional (default 2) OUTPUT: Dictionary of terms of the form (tuple: coeff), where OUTPUT: Dictionary of terms of the form (tuple: coeff), where 'tuple' is an admissible tuple of non-negative integers and 'coeff' is its coefficient.  This corresponds to a linear combination of admissible monomials.  When p is odd, each tuple \beta^{e_1} \mathcal{P}^{i_2} \beta^{e_2} \mathcal{P}^{i_2} ... \mathcal{P}^{i_k} \beta^{e_k} ALGORITHM: Given (i_1, i_2, i_3, ...), apply the Adem relations to the first pair (or triple when p is odd) where the sequence is inadmissible, and then apply this function recursively to each of the resulting tuples (i_1, ..., i_{j-1}, NEW, i_{j+2}, ...), keeping track of the coefficients. ALGORITHM: Given (i_1, i_2, i_3, ...), apply the Adem relations to the first pair (or triple when p is odd) where the sequence is inadmissible, and then apply this function recursively to each of the resulting tuples (i_1, ..., i_{j-1}, NEW, i_{j+2}, ...), keeping track of the coefficients. .. note:: else: ans[m] = y[x] * new[m] return ans make_mono_admissible = CachedFunction(make_mono_admissible_)
• ## sage/categories/coxeter_groups.py

diff --git a/sage/categories/coxeter_groups.py b/sage/categories/coxeter_groups.py
 a r""" INPUT: - word - a list (or iterable) of elements of self.index_set() - word - a list (or iterable) of elements of self.index_set() Returns the group element corresponding to the given word. Namely, if word is [i_1,i_2,\ldots,i_k], then def simple_reflection(self, i): """ INPUT: - i - an element from the index set. Returns the simple reflection s_i def simple_projection(self, i, side = 'right', toward_max = True): r""" INPUT: - i - an element of the index set of self - i - an element of the index set of self Returns the simple projection \pi_i (or \overline\pi_i if toward_max is False). def simple_projections(self, side = 'right', toward_max = True): r""" INPUT: - self - a Coxeter group W - side - 'left' or 'right' (default: 'right') - toward_max - a boolean (default: True) specifying the direction of the projection - self - a Coxeter group W - side - 'left' or 'right' (default: 'right') - toward_max - a boolean (default: True) specifying the direction of the projection Returns the simple projections of W, as a family. def descents(self, side = 'right', index_set=None, positive=False): """ INPUT: - index_set - a subset (as a list or iterable) of the nodes of the dynkin diagram; (default: all of them) - side - 'left' or 'right' (default: 'right') - positive - a boolean (default: False) - index_set - a subset (as a list or iterable) of the nodes of the dynkin diagram; (default: all of them) - side - 'left' or 'right' (default: 'right') - positive - a boolean (default: False) Returns the descents of self, as a list of elements of the index_set. def coset_representative(self, index_set, side = 'right'): r""" INPUT: - index_set - a subset (or iterable) of the nodes of the dynkin diagram - side - 'left' or 'right' - index_set - a subset (or iterable) of the nodes of the dynkin diagram - side - 'left' or 'right' Returns the unique shortest element of the coxeter group $W$ which is in the same left (resp. right) coset as def apply_simple_projection(self, i, side = 'right', toward_max = True): r""" INPUT: - i - an element of the index set of the Coxeter group - side - 'left' or 'right' (default: 'right') - toward_max - a boolean (default: True) specifying the direction of the projection - i - an element of the index set of the Coxeter group - side - 'left' or 'right' (default: 'right') - toward_max - a boolean (default: True) specifying the direction of the projection Returns the result of the application of the simple projection \pi_i (resp. \overline\pi_i) on self. def apply_simple_reflections(self, word, side = 'right'): """ INPUT: - "word": A sequence of indices of Coxeter generators - "side": Indicates multiplying from left or right - "word": A sequence of indices of Coxeter generators - "side": Indicates multiplying from left or right Returns the result of the (left/right) multiplication of word to self.  self is not changed. INPUT: - other - an element of the same Coxeter group - other - an element of the same Coxeter group OUTPUT: a boolean INPUT: - other - an element of the same Coxeter group - side - 'left' or 'right'  (default: 'right') - other - an element of the same Coxeter group - side - 'left' or 'right'  (default: 'right') OUTPUT: a boolean INPUT: - side - 'left' or 'right'  (default: 'right') - positive - a boolean (default: False) - index_set - a list of indices or None - side - 'left' or 'right'  (default: 'right') - positive - a boolean (default: False) - index_set - a list of indices or None OUTPUT: a list INPUT: - side - 'left' or 'right' (default: 'right') - index_set - a list of indices or None - side - 'left' or 'right' (default: 'right') - index_set - a list of indices or None OUTPUT: a list INPUT: - side - 'left' or 'right' (default: 'right') - index_set - a list of indices or None - side - 'left' or 'right' (default: 'right') - index_set - a list of indices or None OUTPUT: a list
• ## sage/categories/finite_coxeter_groups.py

diff --git a/sage/categories/finite_coxeter_groups.py b/sage/categories/finite_coxeter_groups.py
 a INPUT: - index_set - a subset (as a list or iterable) of the nodes of the dynkin diagram; (default: all of them) - index_set - a subset (as a list or iterable) of the nodes of the dynkin diagram; (default: all of them) Returns the longest element of self, or of the parabolic subgroup corresponding to the given index_set. TODO: - Use the symmetric group in the examples (for nicer output), and print the edges for a stronger test. - The constructed poset should be lazy, in order to handle large / infinite Coxeter groups. - Use the symmetric group in the examples (for nicer output), and print the edges for a stronger test. - The constructed poset should be lazy, in order to handle large / infinite Coxeter groups. """ from sage.combinat.posets.posets import Poset covers = tuple([u, v] for v in self for u in v.bruhat_lower_covers() ) """ INPUT: - side -- "left" or "right" (default: "right") - side -- "left" or "right" (default: "right") Returns the left (resp. right) poset for weak order.  In this poset, u is smaller than v if some reduced word TODO: - Use the symmetric group in the examples (for nicer output), and print the edges for a stronger test. - The constructed poset should be lazy, in order to handle large / infinite Coxeter groups. - Use the symmetric group in the examples (for nicer output), and print the edges for a stronger test. - The constructed poset should be lazy, in order to handle large / infinite Coxeter groups. """ from sage.combinat.posets.posets import Poset
• ## sage/categories/finite_semigroups.py

diff --git a/sage/categories/finite_semigroups.py b/sage/categories/finite_semigroups.py
 a Two elements $u$ and $v$ of a monoid are in the same $J$-class if $u$ divides $v$ and $v$ divides $u$. OUTPUT:: OUTPUT: All the $J$-classes of self, as a list of lists. r""" Returns all the idempotents of self, grouped by J-class. OUTPUT:: OUTPUT: a list of lists.
• ## sage/categories/monoids.py

diff --git a/sage/categories/monoids.py b/sage/categories/monoids.py
 a r""" Returns the one of the monoid, that is the unique neutral element for *. .. note: .. note:: The default implementation is to coerce 1 into self. It is recommended to override this method because the coercion from the integers:: coercion from the integers: - is not always meaningful (except for 1); - often uses self.one().
• ## sage/misc/cachefunc.pyx

diff --git a/sage/misc/cachefunc.pyx b/sage/misc/cachefunc.pyx
 a assignment, it can inherit a cached method from the parent class of a category (previously, the cache would have been broken):: sage: cython_code = ["from sage.all import cached_method, cached_in_parent_method, Category", sage: cython_code = ["from sage.all import cached_method, cached_in_parent_method, Category, Objects", ... "class MyCategory(Category):", ... "    @cached_method", ... "    def super_categories(self):", filename = filename[len(SAGE_ROOT+'/devel/sage/'):] elif 'site-packages/' in filename: filename = filename.split('site-packages/',1)[1] file_info = "File: %s (starting at line %d)"%(filename,sourcelines[1]) file_info = "File: %s (starting at line %d)\n"%(filename,sourcelines[1]) doc = file_info+(f.func_doc or '') else: doc = f.func_doc
• ## sage/structure/dynamic_class.py

diff --git a/sage/structure/dynamic_class.py b/sage/structure/dynamic_class.py
 a True We check that instrospection works reasonably:: sage: import inspect sage: inspect.getfile(Foo2) '.../sage/structure/dynamic_class.pyc'
• ## sage/structure/element.pyx

diff --git a/sage/structure/element.pyx b/sage/structure/element.pyx
 a ... "cdef class MyParent(Parent):", ... "    Element = MyElement"] sage: cython('\n'.join(cython_code)) sage: cython_code = ["from sage.all import cached_method, cached_in_parent_method, Category", sage: cython_code = ["from sage.all import cached_method, cached_in_parent_method, Category, Objects", ... "class MyCategory(Category):", ... "    @cached_method", ... "    def super_categories(self):", ... "from sage.structure.parent cimport Parent", ... "cdef class MyParent(Parent):", ... "    Element = MyElement", ... "from sage.all import cached_method, lazy_attribute, Category", ... "from sage.all import cached_method, lazy_attribute, Category, Objects", ... "class MyCategory(Category):", ... "    @cached_method", ... "    def super_categories(self):",