# Ticket #5600: trac_5600-reviewer.patch

File trac_5600-reviewer.patch, 6.8 KB (added by mvngu, 13 years ago)

reviewer patch

• ## sage/combinat/composition.py

```# HG changeset patch
# User Minh Van Nguyen <nguyenminh2@gmail.com>
# Date 1250981838 25200
# Node ID 3c8236e742c7503633d8be5ac9e2531c9de045dc
# Parent  61acc2052f70ee513591204f183055c08e8394a0
trac 5600: fix typos and some minor cosmetic adjustments

diff -r 61acc2052f70 -r 3c8236e742c7 sage/combinat/composition.py```
 a A composition `c` of a nonnegative integer `n` is a list of positive integers (the *parts* of the compositions) with total sum `n`. This module provide tools for manipulating compositions and enumerated This module provides tools for manipulating compositions and enumerated sets of compositions. EXAMPLES:: AUTHORS: - Mike Hansen, Nicolas M. Thiery - MuPAD-Combinat developers (algorithms and design inspiration) - Mike Hansen, Nicolas M. Thiery - MuPAD-Combinat developers (algorithms and design inspiration) """ #***************************************************************************** #       Copyright (C) 2007 Mike Hansen        @staticmethod def sum(compositions): """ Returns the concatenation of the given compositions. INPUT: - ``compositions``: a list (or iterable) of compositions Returns the concatenation of the given compositions - ``compositions`` -- a list (or iterable) of compositions EXAMPLES:: sage: sage.combinat.composition.Composition_class.sum([Composition([i,i]) for i in [4,1,3]]) [4, 4, 1, 1, 3, 3] Empty inputs are handled gracefuly:: Empty inputs are handled gracefully:: sage: sage.combinat.composition.Composition_class.sum([]) == Composition([]) True def finer(self): """ Returns the set of compositions which are finer than self Returns the set of compositions which are finer than self. EXAMPLES:: def fatten(self, grouping): """ Returns the composition fatter than self, obtained by grouping together consecutive parts according to grouping. INPUT: - ``grouping`` - a composition whose sum is the length of self Returns the composition fatter than self, obtained by grouping together consecutive parts according to grouping. - ``grouping`` -- a composition whose sum is the length of self EXAMPLES: sage: c.fatten(Composition([5])) [19] Other values for `grouping` yield (all the) other compositions coarser to `c`:: Other values for ``grouping`` yield (all the) other compositions coarser to `c`:: sage: c.fatten(Composition([2,1,2])) [9, 2, 8] def fatter(self): """ Returns the set of compositions which are fatter than self Returns the set of compositions which are fatter than self. Complexity for generation: O(size(c)) memory, O(size(result)) time sage: list(Composition([1,1,1,1]).fatter()) == list(Compositions(4)) True """ return Compositions(len(self)).map(self.fatten) def refinement(self, co2): def Compositions(n=None, **kwargs): r""" Sets of integer Compositions Sets of integer Compositions. A composition `c` of a nonnegative integer `n` is a list of positive integers with total sum `n`. See also: `Composition`, `Partitions`, `IntegerVectors` See also: ``Composition``, ``Partitions``, ``IntegerVectors`` EXAMPLES: sage: list(Compositions(4)) [[1, 1, 1, 1], [1, 1, 2], [1, 2, 1], [1, 3], [2, 1, 1], [2, 2], [3, 1], [4]] You can use the .first() method to get the 'first' composition of You can use the ``.first()`` method to get the 'first' composition of a number:: sage: Compositions(4).first() sage: Compositions(3).cardinality() 4 The following examples shows how to test whether or not an object The following examples show how to test whether or not an object is a composition:: sage: [3,4] in Compositions() Note that if you specify min_part=0, then the objects produced may have parts equal to zero. This violates the internal assumptions that the Composition class makes. Use at your own risk, or preferably consider using `IntegerVectors` instead:: preferably consider using ``IntegerVectors`` instead:: sage: list(Compositions(2, length=3, min_part=0)) doctest:... RuntimeWarning: Currently, setting min_part=0 produces Composition objects which violate internal assumptions.  Calling methods on these objects may produce errors or WRONG results! [[2, 0, 0], [1, 1, 0], [1, 0, 1], [0, 2, 0], [0, 1, 1], [0, 0, 2]] The generation algorithm is constant amortized time, and handled by the generic tool `IntegerListsLex`. by the generic tool ``IntegerListsLex``. TESTS:: # Those belong to the Compositino class # Those belong to the Composition class def from_descents(descents, nps=None): """
• ## sage/combinat/skew_partition.py

`diff -r 61acc2052f70 -r 3c8236e742c7 sage/combinat/skew_partition.py`
 a def __init__(self, n, overlap=0): """ INPUT: - n: an non negative integer - overlap: an integer - ``n`` -- a non-negative integer - ``overlap`` -- an integer Returns the set of the skew partitions of ``n`` with overlap at least ``overlap``, and no empty row. Caveat: this set is stable under conjugation only for overlap= 0 or 1. What exactly happens for negative overlaps is not yet well specified, and subject to change (we may want to introduce vertical overlap constraints as well). overlap would also better be named min_overlap. introduce vertical overlap constraints as well). ``overlap`` would also better be named ``min_overlap``. Todo: as is, this set is essentially the composition of Compositions(n) (which give the row lengths) and SkewPartition(n, row_lengths=...), and one would want to ``Compositions(n)`` (which give the row lengths) and ``SkewPartition(n, row_lengths=...)``, and one would want to "inherit" list and cardinality from this composition. TESTS::