Ticket #8703: trac_8703-review-fc.patch

File trac_8703-review-fc.patch, 11.2 KB (added by chapoton, 6 years ago)
  • sage/combinat/abstract_tree.py

    # HG changeset patch
    # User Frederic Chapoton <chapoton at math.univ-lyon1.fr>
    # Date 1364758130 -7200
    # Node ID 7607282f2929d85df5beabb9573ab3bdf2c9af43
    # Parent  637ceed9ae5215027c8002eddeaeac542d6698c2
    trac #8703 review patch, small changes
    
    diff --git a/sage/combinat/abstract_tree.py b/sage/combinat/abstract_tree.py
    a b  
    1 """
     1# -*- coding: utf-8 -*-
     2r"""
    23Abstract Recursive Trees
    34
    45The purpose of this class is to help implement trees with a specific structure
    incoherent with the data structure. 
    5960**Authors**
    6061
    6162- Florent Hivert (2010-2011): initial revision
    62 - Frederic Chapoton (2011): contributed some methods
     63- Frédéric Chapoton (2011): contributed some methods
    6364"""
    6465
    6566from sage.structure.list_clone import ClonableArray
    class AbstractClonableTree(AbstractTree) 
    425426        <sage.combinat.abstract_tree.AbstractTree>` also extend
    426427        :class:`sage.structure.list_clone.ClonableElement`, which requires it.
    427428
    428         It should be overriden in subclass is order to chech that the
     429        It should be overriden in subclass in order to check that the
    429430        invariant of the kind of tree holds (eg: two children for binary
    430431        trees).
    431432
    class AbstractClonableTree(AbstractTree) 
    457458
    458459        EXAMPLES:
    459460
    460         Trying to modify a non mutable tree raise an error::
     461        Trying to modify a non mutable tree raises an error::
    461462
    462463            sage: x = OrderedTree([])
    463464            sage: x[0] =  OrderedTree([[]])
    class AbstractClonableTree(AbstractTree) 
    473474            sage: x
    474475            [[[]], [[]]]
    475476
    476         One can also substitute at any depths::
     477        One can also substitute at any depth::
    477478
    478479            sage: y = OrderedTree(x)
    479480            sage: with x.clone() as x:
    class AbstractClonableTree(AbstractTree) 
    541542
    542543        - ``idx`` -- a valid path in ``self`` identifying a node
    543544
    544         ..note::
     545        .. NOTE::
    545546
    546             The default implementation here assume that the container of the
     547            The default implementation here assumes that the container of the
    547548            node inherits from
    548549            :class:`~sage.structure.list_clone.ClonableArray`.
    549550
    class AbstractLabelledTree(AbstractTree) 
    600601        ``LabelledOrderedTrees()`` and ``T.parent().unlabelled_trees()`` is
    601602        ``OrderedTrees()``
    602603
    603     * In the same vein, the class of ``T`` should contains an attribute
     604    * In the same vein, the class of ``T`` should contain an attribute
    604605      ``_Unlabelled`` which should be the class for the corresponding
    605606      unlabelled trees.
    606607
    class AbstractLabelledTree(AbstractTree) 
    659660        - ``path`` -- None (default) or a path (list or tuple of children index
    660661                     in the tree)
    661662
    662         OUTPUT: the label of the subtree at indexed by ``path``
     663        OUTPUT: the label of the subtree indexed by ``path``
    663664
    664665        EXAMPLES::
    665666
    class AbstractLabelledTree(AbstractTree) 
    769770            sage: LabelledBinaryTree([[],[[],[]]], label = 25).__hash__() #random
    770771            8544617749928727644
    771772
    772         We check that the hash value depend on the value of the labels of the
     773        We check that the hash value depends on the value of the labels of the
    773774        subtrees::
    774775
    775776            sage: LBT = LabelledBinaryTree
    class AbstractLabelledTree(AbstractTree) 
    815816        .. WARNING::
    816817
    817818            At this time, the output makes sense only if ``self`` is a
    818             labelled binary tree with no repeated labels and no "None"
     819            labelled binary tree with no repeated labels and no ``None``
    819820            labels.
    820821
    821822        EXAMPLES::
    class AbstractLabelledClonableTree(Abstr 
    845846    """
    846847    Abstract Labelled Clonable Tree
    847848
    848     This class take care of modification for the label by the clone protocol.
     849    This class takes care of modification for the label by the clone protocol.
    849850
    850851    .. NOTE:: Due to the limitation of Cython inheritance, one cannot inherit
    851852       here from :class:`ClonableArray`, because it would prevent us to
    class AbstractLabelledClonableTree(Abstr 
    879880            sage: t
    880881            3[None[], None[None[], None[]]]
    881882
    882         This also work for binary trees::
     883        This also works for binary trees::
    883884
    884885            sage: bt = LabelledBinaryTree([[],[]])
    885886            sage: bt.set_root_label(3)
  • sage/combinat/binary_tree.py

    diff --git a/sage/combinat/binary_tree.py b/sage/combinat/binary_tree.py
    a b class BinaryTree(AbstractClonableTree, C 
    245245
    246246        The actual canonical labelling is currently unspecified. However, it
    247247        is guaranteed to have labels in `1...n` where `n` is the number of
    248         node of the tree. Moreover, two (unlabelled) trees compare as equal if
    249         and only if they canonical labelled trees compare as equal.
     248        nodes of the tree. Moreover, two (unlabelled) trees compare as equal if
     249        and only if their canonical labelled trees compare as equal.
    250250
    251251        EXAMPLES::
    252252
    class BinaryTree(AbstractClonableTree, C 
    323323
    324324        .. NOTE:: ``self`` must be in a mutable state.
    325325
    326         .. seealso::
     326        .. SEEALSO::
    327327            :meth:`make_node <sage.combinat.binary_tree.BinaryTree.make_node>`
    328328
    329329        EXAMPLES::
    class BinaryTree(AbstractClonableTree, C 
    406406
    407407        The number of pairs `(t_1, t_2)` of binary trees of size `n` such that
    408408        the canopee of `t_1` is the complementary of the canopee of `t_2` is
    409         also the number of Baxter permutations (see [DG]_, see also sequences
    410         A001181 in Sloane's database). We check this in small cases::
     409        also the number of Baxter permutations (see [DG]_, see
     410        also :oeis:`A001181`). We check this in small cases::
    411411
    412412            sage: [len([(u,v) for u in BinaryTrees(n) for v in BinaryTrees(n)
    413413            ...       if map(lambda x:1-x, u.canopee()) == v.canopee()])
    class BinaryTrees(UniqueRepresentation,  
    486486    .. NOTE:: this in a factory class whose constructor returns instances of
    487487              subclasses.
    488488
    489     .. NOTE:: the fact that OrderedTrees is a class instead a simple callable
     489    .. NOTE:: the fact that OrderedTrees is a class instead of a simple callable
    490490              is an implementation detail. It could be changed in the future
    491491              and one should not rely on it.
    492492    """
    class BinaryTrees_size(BinaryTrees): 
    693693
    694694    def cardinality(self):
    695695        """
    696         The cardinality of self
     696        The cardinality of ``self``
    697697
    698698        This is a Catalan number.
    699699
    class LabelledBinaryTree(AbstractLabelle 
    794794    def __classcall_private__(cls, *args, **opts):
    795795        """
    796796        Ensure that trees created by the sets and directly are the same and
    797         that they are instance of :class:`LabelledTree`
     797        that they are instances of :class:`LabelledTree`
    798798
    799799        TESTS::
    800800
    class LabelledBinaryTree(AbstractLabelle 
    813813        """
    814814        The automatic parent of the element of this class
    815815
    816         When calling the constructor of an element of this class, one need a
     816        When calling the constructor of an element of this class, one needs a
    817817        parent. This class attribute specifies which parent is used.
    818818
    819819        EXAMPLES::
  • sage/combinat/ordered_tree.py

    diff --git a/sage/combinat/ordered_tree.py b/sage/combinat/ordered_tree.py
    a b class OrderedTree(AbstractClonableTree,  
    2828
    2929    An ordered tree is constructed from a node called the root on which one
    3030    has grafted a possibly empty list of trees. There is a total order on the
    31     children of a node which is given by the order of the element in the
     31    children of a node which is given by the order of the elements in the
    3232    list. Note that there is no empty ordered tree.
    3333
    3434    INPUT:
    class OrderedTree(AbstractClonableTree,  
    6464    :class:`sage.structure.list_clone.ClonableList`. So that they can be
    6565    modified using the clone protocol:
    6666
    67     Trying to modify a non mutable tree raise an error::
     67    Trying to modify a non mutable tree raises an error::
    6868
    6969        sage: tt1[1] = tt2
    7070        Traceback (most recent call last):
    class OrderedTree(AbstractClonableTree,  
    168168    def __classcall_private__(cls, *args, **opts):
    169169        """
    170170        Ensure that trees created by the enumerated sets and directly
    171         are the same and that they are instance of :class:`OrderedTree`
     171        are the same and that they are instances of :class:`OrderedTree`
    172172
    173173        TESTS::
    174174
    class OrderedTree(AbstractClonableTree,  
    199199        """
    200200        The automatic parent of the element of this class
    201201
    202         When calling the constructor of an element of this class, one need a
     202        When calling the constructor of an element of this class, one needs a
    203203        parent. This class attribute specifies which parent is used.
    204204
    205205        EXAMPLES::
    class OrderedTrees(UniqueRepresentation, 
    289289        sage: OrderedTrees(2)
    290290        Ordered trees of size 2
    291291
    292     .. NOTE:: this in a factory class whose constructor returns instances of
     292    .. NOTE:: this is a factory class whose constructor returns instances of
    293293              subclasses.
    294294
    295     .. NOTE:: the fact that OrderedTrees is a class instead a simple callable
     295    .. NOTE:: the fact that OrderedTrees is a class instead of a simple callable
    296296              is an implementation detail. It could be changed in the future
    297297              and one should not rely on it.
    298298    """
    class OrderedTrees_size(OrderedTrees): 
    578578            sage: S([])   # indirect doctest
    579579            Traceback (most recent call last):
    580580            ...
    581             ValueError: Wrong number of nodes
     581            ValueError: wrong number of nodes
    582582
    583583            sage: S = OrderedTrees(1)   # indirect doctest
    584584            sage: S([])
    class OrderedTrees_size(OrderedTrees): 
    586586        """
    587587        res = self.element_class(self._parent_for, *args, **keywords)
    588588        if res.node_number() != self._size:
    589             raise ValueError, "Wrong number of nodes"
     589            raise ValueError("wrong number of nodes")
    590590        return res
    591591
    592592
    class LabelledOrderedTree(AbstractLabell 
    595595    Labelled ordered trees
    596596
    597597    A labelled ordered tree is an ordered tree with a label attached at each
    598     node
     598    node.
    599599
    600600    INPUT:
    601601
    class LabelledOrderedTree(AbstractLabell 
    620620    def __classcall_private__(cls, *args, **opts):
    621621        """
    622622        Ensure that trees created by the sets and directly are the same and
    623         that they are instance of :class:`LabelledOrderedTree`
     623        that they are instances of :class:`LabelledOrderedTree`
    624624
    625625        TESTS::
    626626
    class LabelledOrderedTree(AbstractLabell 
    639639        """
    640640        The automatic parent of the element of this class
    641641
    642         When calling the constructor of an element of this class, one need a
     642        When calling the constructor of an element of this class, one needs a
    643643        parent. This class attribute specifies which parent is used.
    644644
    645645        EXAMPLES::