Ticket #13747: trac_13747.patch

File trac_13747.patch, 33.0 KB (added by ncohen, 8 years ago)
  • sage/combinat/posets/elements.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1353725066 -3600
    # Node ID 5fbca18f0f90bcefcf1d37f87d6069855b63cc3c
    # Parent  b5bbe67684871630c211855b34ae0112d598f799
    Change default behaviour of Poset to facade = True
    
    diff --git a/sage/combinat/posets/elements.py b/sage/combinat/posets/elements.py
    a b  
    3838        TESTS::
    3939       
    4040            sage: from sage.combinat.posets.elements import PosetElement
    41             sage: P = Poset([[1,2],[4],[3],[4],[]])
     41            sage: P = Poset([[1,2],[4],[3],[4],[]], facade = False)
    4242            sage: e = P(0)
    4343            sage: e.parent() is P
    4444            True
     
    5555        """
    5656        TESTS::
    5757       
    58             sage: Poset([[1,2],[4],[3],[4],[]])(0)._repr_()
     58            sage: Poset([[1,2],[4],[3],[4],[]], facade = False)(0)._repr_()
    5959            '0'
    6060        """
    6161        return "%s" %str(self.element)
     
    6868
    6969            sage: m = matrix(2,[1,2,3,4])
    7070            sage: m.set_immutable()
    71             sage: P = Poset(([m],[]))
     71            sage: P = Poset(([m],[]), facade = False)
    7272            sage: [e] = P
    7373            sage: type(e)
    7474            <class 'sage.combinat.posets.elements.FinitePoset_with_category.element_class'>
     
    8585        """
    8686        TESTS::
    8787
    88             sage: P = Poset([["a","b"],["d"],["c"],["d"],[]])
    89             sage: Q = Poset([["a","b"],["d"],["c"],[],[]])
     88            sage: P = Poset([["a","b"],["d"],["c"],["d"],[]], facade = False)
     89            sage: Q = Poset([["a","b"],["d"],["c"],[],[]], facade = False)
    9090            sage: P(0).__eq__(P(4))
    9191            False
    9292            sage: from sage.combinat.posets.elements import PosetElement
     
    142142        """
    143143        TESTS::
    144144       
    145             sage: P = Poset([[1,2],[4],[3],[4],[]])
     145            sage: P = Poset([[1,2],[4],[3],[4],[]], facade = False)
    146146            sage: P(0)._cmp(P(4))
    147147            -1
    148148            sage: P(4)._cmp(P(0))
     
    175175
    176176        TESTS::
    177177       
    178             sage: P = Poset([[1,2],[4],[3],[4],[]])
     178            sage: P = Poset([[1,2],[4],[3],[4],[]], facade = False)
    179179            sage: P(0).__cmp__(P(4))
    180180            -1
    181181            sage: P(4).__cmp__(P(0))
     
    211211        ::
    212212       
    213213            sage: dag = DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]})
    214             sage: P = Poset(dag)
     214            sage: P = Poset(dag, facade = False)
    215215            sage: P(0) < P(1)
    216216            False
    217217            sage: P(4) < P(1)
     
    228228        ::
    229229       
    230230            sage: dag = DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]})
    231             sage: P = Poset(dag)
     231            sage: P = Poset(dag, facade = False)
    232232            sage: P(1) <= P(0)
    233233            False
    234234            sage: P(0) <= P(1)
  • sage/combinat/posets/lattices.py

    diff --git a/sage/combinat/posets/lattices.py b/sage/combinat/posets/lattices.py
    a b  
    329329    P = Poset(data, *args, **options)
    330330    if not P.is_lattice():
    331331        raise ValueError, "Not a lattice."
    332     return FiniteLatticePoset(P, category = FiniteLatticePosets())
     332
     333    return FiniteLatticePoset(P, category = FiniteLatticePosets(), facade = P._is_facade)
    333334
    334335class FiniteLatticePoset(FiniteMeetSemilattice, FiniteJoinSemilattice):
    335336    """
  • sage/combinat/posets/linear_extensions.py

    diff --git a/sage/combinat/posets/linear_extensions.py b/sage/combinat/posets/linear_extensions.py
    a b  
    5050
    5151    EXAMPLES::
    5252
    53         sage: P = Poset(([1,2,3,4], [[1,3],[1,4],[2,3]]), linear_extension=True)
     53        sage: P = Poset(([1,2,3,4], [[1,3],[1,4],[2,3]]), linear_extension=True, facade = False)
    5454        sage: p = P.linear_extension([1,4,2,3]); p
    5555        [1, 4, 2, 3]
    5656        sage: p.parent()
     
    183183
    184184        EXAMPLES::
    185185
    186             sage: P = Poset(([1,2,3,4], [[1,2],[1,3],[3,4]]))
     186            sage: P = Poset(([1,2,3,4], [[1,2],[1,3],[3,4]]), facade = False)
    187187            sage: p = P.linear_extension([1,3,4,2])
    188188            sage: Q = p.to_poset(); Q
    189189            Finite poset containing 4 elements
  • sage/combinat/posets/posets.py

    diff --git a/sage/combinat/posets/posets.py b/sage/combinat/posets/posets.py
    a b  
    22r"""
    33Posets
    44
    5 This module implements finite partialy ordered sets. The main
    6 constructor is :meth:`Poset`.
     5This module implements finite partialy ordered sets. It defines :
     6
     7.. csv-table::
     8    :class: contentstable
     9    :widths: 30, 70
     10    :delim: |
     11
     12    :class:`FinitePoset` | A class for finite posets
     13    :class:`FinitePosets_n` | A class for finite posets up to isomorphism (i.e. unlabeled posets)
     14    :meth:`Poset` | Construct a finite poset from various forms of input data.
     15    :meth:`is_poset` | Tests whether a directed graph is acyclic and transitively reduced.
     16
     17**List of Poset methods**
     18
     19.. csv-table::
     20    :class: contentstable
     21    :widths: 30, 70
     22    :delim: |
     23
     24    :meth:`~FinitePoset.antichains_iterator` | Returns an iterator over the antichains of the poset.
     25    :meth:`~FinitePoset.antichains` | Returns the antichains of the poset.
     26    :meth:`~FinitePoset.bottom` | Returns the bottom element of the poset, if it exists.
     27    :meth:`~FinitePoset.cardinality` | Returns the number of elements in the poset.
     28    :meth:`~FinitePoset.chains` | Returns all the chains of ``self``
     29    :meth:`~FinitePoset.closed_interval` | Returns a list of the elements `z` such that `x \le z \le y`.
     30    :meth:`~FinitePoset.compare_elements` | Compare `x` and `y` in the poset.
     31    :meth:`~FinitePoset.cover_relations_iterator` | Returns an iterator for the cover relations of the poset.
     32    :meth:`~FinitePoset.cover_relations` | Returns the list of pairs [u,v] which are cover relations
     33    :meth:`~FinitePoset.covers` | Returns True if y covers x and False otherwise.
     34    :meth:`~FinitePoset.coxeter_transformation` | Returns the matrix of the Auslander-Reiten translation acting on the Grothendieck group of the derived category of modules
     35    :meth:`~FinitePoset.dual` | Returns the dual poset of the given poset.
     36    :meth:`~FinitePoset.evacuation` | Computes evacuation on the linear extension associated to the poset ``self``.
     37    :meth:`~FinitePoset.graphviz_string` | Returns a representation in the DOT language, ready to render in graphviz.
     38    :meth:`~FinitePoset.has_bottom` | Returns True if the poset has a unique minimal element.
     39    :meth:`~FinitePoset.hasse_diagram` | Returns the Hasse diagram of ``self`` as a Sage :class:`DiGraph`.
     40    :meth:`~FinitePoset.has_top` | Returns True if the poset contains a unique maximal element, and False otherwise.
     41    :meth:`~FinitePoset.interval` | Returns a list of the elements `z` such that `x \le z \le y`.
     42    :meth:`~FinitePoset.is_bounded` | Returns True if the poset contains a unique maximal element and a unique minimal element, and False otherwise.
     43    :meth:`~FinitePoset.is_chain` | Returns True if the poset is totally ordered, and False otherwise.
     44    :meth:`~FinitePoset.is_gequal` | Returns ``True`` if `x` is greater than or equal to `y` in the poset, and ``False`` otherwise.
     45    :meth:`~FinitePoset.is_graded` | Returns whether this poset is graded.
     46    :meth:`~FinitePoset.is_greater_than` | Returns ``True`` if `x` is greater than but not equal to `y` in the poset, and ``False`` otherwise.
     47    :meth:`~FinitePoset.is_isomorphic` | Returns True if both posets are isomorphic.
     48    :meth:`~FinitePoset.is_join_semilattice` | Returns True is the poset has a join operation, and False otherwise.
     49    :meth:`~FinitePoset.is_lequal` | Returns ``True`` if `x` is less than or equal to `y` in the poset, and ``False`` otherwise.
     50    :meth:`~FinitePoset.is_less_than` | Returns ``True`` if `x` is less than but not equal to `y` in the poset, and ``False`` otherwise.
     51    :meth:`~FinitePoset.is_linear_extension` | Returns whether ``l`` is a linear extension of ``self``
     52    :meth:`~FinitePoset.is_meet_semilattice` | Returns True if self has a meet operation, and False otherwise.
     53    :meth:`~FinitePoset.join_matrix` | Returns a matrix whose ``(i,j)`` entry is ``k``, where ``self.linear_extension()[k]`` is the join (least upper bound) of ``self.linear_extension()[i]`` and ``self.linear_extension()[j]``.
     54    :meth:`~FinitePoset.is_ranked` | Returns whether this poset is ranked.
     55    :meth:`~FinitePoset.is_slender` | Returns whether the poset ``self`` is slender or not.
     56    :meth:`~FinitePoset.lequal_matrix` | Computes the matrix whose ``(i,j)`` entry is 1 if ``self.linear_extension()[i] < self.linear_extension()[j]`` and 0 otherwise
     57    :meth:`~FinitePoset.level_sets` | Returns a list l such that l[i+1] is the set of minimal elements of the poset obtained by removing the elements in l[0], l[1], ..., l[i].
     58    :meth:`~FinitePoset.linear_extension` | Returns a linear extension of this poset.
     59    :meth:`~FinitePoset.linear_extensions` | Returns the enumerated set of all the linear extensions of this poset
     60    :meth:`~FinitePoset.list` | List the elements of the poset. This just returns the result of :meth:`linear_extension`.
     61    :meth:`~FinitePoset.lower_covers_iterator` | Returns an iterator for the lower covers of the element y. An lower cover of y is an element x such that y x is a cover relation.
     62    :meth:`~FinitePoset.lower_covers` | Returns a list of lower covers of the element y. An lower cover of y is an element x such that y x is a cover relation.
     63    :meth:`~FinitePoset.maximal_chains` | Returns all maximal chains of this poset.  Each chain is listed in increasing order.
     64    :meth:`~FinitePoset.maximal_elements` | Returns a list of the maximal elements of the poset.
     65    :meth:`~FinitePoset.meet_matrix` | Returns a matrix whose ``(i,j)`` entry is ``k``, where ``self.linear_extension()[k]`` is the meet (greatest lower bound) of ``self.linear_extension()[i]`` and ``self.linear_extension()[j]``.
     66    :meth:`~FinitePoset.minimal_elements` | Returns a list of the minimal elements of the poset.
     67    :meth:`~FinitePoset.mobius_function_matrix` | Returns a matrix whose ``(i,j)`` entry is the value of the Mobius function evaluated at ``self.linear_extension()[i]`` and ``self.linear_extension()[j]``.
     68    :meth:`~FinitePoset.mobius_function` | Returns the value of the Mobius function of the poset on the elements x and y.
     69    :meth:`~FinitePoset.open_interval` | Returns a list of the elements `z` such that `x < z < y`. The order is that induced by the ordering in
     70    :meth:`~FinitePoset.order_complex` | Returns the order complex associated to this poset.
     71    :meth:`~FinitePoset.order_filter` | Returns the order filter generated by a list of elements.
     72    :meth:`~FinitePoset.order_ideal` | Returns the order ideal generated by a list of elements.
     73    :meth:`~FinitePoset.plot` | Returns a Graphic object corresponding the Hasse diagram of the poset.
     74    :meth:`~FinitePoset.product` | Returns the cartesian product of ``self`` and ``other``.
     75    :meth:`~FinitePoset.promotion` | Computes the (extended) promotion on the linear extension of the poset ``self``
     76    :meth:`~FinitePoset.random_subposet` | Returns a random subposet that contains each element with probability p.
     77    :meth:`~FinitePoset.rank_function` | Returns a rank function of the poset, if it exists.
     78    :meth:`~FinitePoset.rank` | Returns the rank of an element, or the rank of the poset if element is None.
     79    :meth:`~FinitePoset.relabel` | Returns a copy of this poset with its elements relabelled
     80    :meth:`~FinitePoset.relations_iterator` | Returns an iterator for all the relations of the poset.
     81    :meth:`~FinitePoset.relations` | Returns a list of all relations of the poset.
     82    :meth:`~FinitePoset.show` | Shows the Graphics object corresponding the Hasse diagram of the poset.
     83    :meth:`~FinitePoset.subposet` | Returns the poset containing elements with partial order induced by that of self.
     84    :meth:`~FinitePoset.top` | Returns the top element of the poset, if it exists.
     85    :meth:`~FinitePoset.unwrap` | Unwraps an element of this poset
     86    :meth:`~FinitePoset.upper_covers_iterator` | Returns an iterator for the upper covers of the element y. An upper cover of y is an element x such that y x is a cover relation.
     87    :meth:`~FinitePoset.upper_covers` | Returns a list of upper covers of the element y. An upper cover of y is an element x such that y x is a cover relation.
     88    :meth:`~FinitePoset.with_linear_extension` | Returns a copy of ``self`` with a different default linear extension
     89
     90Classes and functions
     91---------------------
    792"""
    893#*****************************************************************************
    994#       Copyright (C) 2008 Peter Jipsen <jipsen@chapman.edu>,
     
    91176      use the provided list of elements as default linear extension
    92177      for the poset; otherwise a linear extension is computed.
    93178
    94     - ``facade`` -- a boolean (default: False); whether the Poset's
    95       elements should be wrapped to make them aware of the Poset they
    96       belong to. See below for details.
     179    - ``facade`` -- a boolean or ``None`` (default); whether the
     180      :meth:`Poset`'s elements should be wrapped to make them aware of the Poset
     181      they belong to.
     182
     183      * If ``facade = True``, the :meth:`Poset`'s elements are exactly those
     184        given as input.
     185
     186      * If ``facade = False``, the :meth:`Poset`'s elements will become
     187        :class:`~sage.combinat.posets.posets.PosetElement` objects.
     188
     189      * If ``facade = None`` (default) the expected behaviour is the behaviour
     190        of ``facade = True``, unless the opposite can be deduced from the
     191        context (i.e. for instance if a :meth:`Poset` is built from another
     192        :meth:`Poset`, itself built with ``facade = False``)
    97193
    98194    OUTPUT:
    99195
    100         ``FinitePoset`` -- an instance of the ``FinitePoset`` class.
     196        ``FinitePoset`` -- an instance of the :class:`FinitePoset`` class.
    101197
    102198    If ``category`` is specified, then the poset is created in this
    103199    category instead of :class:`FinitePosets`.
     
    110206
    111207          sage: elms = [1,2,3,4,5,6,7]
    112208          sage: rels = [[1,2],[3,4],[4,5],[2,5]]
    113           sage: Poset((elms, rels), cover_relations = True)
     209          sage: Poset((elms, rels), cover_relations = True, facade = False)
    114210          Finite poset containing 7 elements
    115211
    116212       Elements and non-cover relations::
     
    157253       A list of upper covers and a dictionary of labels::
    158254
    159255          sage: elm_labs = {0:"a",1:"b",2:"c",3:"d",4:"e"}
    160           sage: P = Poset([[1,2],[4],[3],[4],[]],elm_labs)
     256          sage: P = Poset([[1,2],[4],[3],[4],[]],elm_labs, facade = False)
    161257          sage: P.list()
    162258          [a, b, c, d, e]
    163259
     
    176272          Finite poset containing 6 elements
    177273
    178274       Any directed acyclic graph without loops or multiple edges, as long
    179        as cover_relations=False::
     275       as ``cover_relations=False``::
    180276
    181277          sage: dig = DiGraph({0:[2,3], 1:[3,4,5], 2:[5], 3:[5], 4:[5]})
    182278          sage: dig.allows_multiple_edges()
     
    222318
    223319    .. rubric:: Facade posets
    224320
    225     By default, the elements of a poset are wrapped so as to make them
    226     aware that they belong to that poset::
    227 
    228         sage: P = Poset(DiGraph({'d':['c','b'],'c':['a'],'b':['a']}))
     321    When ``facade = False``, the elements of a poset are wrapped so as to make
     322    them aware that they belong to that poset::
     323
     324        sage: P = Poset(DiGraph({'d':['c','b'],'c':['a'],'b':['a']}), facade = False)
    229325        sage: d,c,b,a = list(P)
    230326        sage: a.parent() is P
    231327        True
     
    251347        sage: a.element + b.element
    252348        'ac'
    253349
    254     Alternatively, one can construct instead facade posets::
    255 
    256         sage: P = Poset(DiGraph({'d':['c','b'],'c':['a'],'b':['a']}),
    257         ...             facade = True)
     350    By default, facade posets are constructed instead::
     351
     352        sage: P = Poset(DiGraph({'d':['c','b'],'c':['a'],'b':['a']}))
    258353
    259354    In this example, the elements of the poset remain plain strings::
    260355
     
    299394        vertices of a poset to :class:`Integer`'s if they are
    300395        :class:`int`'s::
    301396
    302             sage: P = Poset((divisors(15), attrcall("divides")))
     397            sage: P = Poset((divisors(15), attrcall("divides")), facade = False)
    303398            sage: type(P.an_element().element)
    304399            <type 'sage.rings.integer.Integer'>
    305400
     
    343438    :class:`UniqueRepresentation`. It is otherwise ignored by the
    344439    poset constructor.
    345440
    346 
    347441    TESTS::
    348442
    349443        sage: P = Poset([[1,2],[3],[3]])
     
    466560
    467561    - ``category`` -- :class:`FinitePosets`, or a subcategory thereof.
    468562
    469     - ``facade`` -- a boolean or ``None`` (the default).
     563    - ``facade`` -- a boolean or ``None`` (default); whether the
     564      :class:`~sage.combinat.posets.posets.FinitePoset`'s elements should be
     565      wrapped to make them aware of the Poset they belong to.
     566
     567      * If ``facade = True``, the
     568        :class:`~sage.combinat.posets.posets.FinitePoset`'s elements are exactly
     569        those given as input.
     570
     571      * If ``facade = False``, the
     572        :class:`~sage.combinat.posets.posets.FinitePoset`'s elements will become
     573        :class:`~sage.combinat.posets.posets.PosetElement` objects.
     574
     575      * If ``facade = None`` (default) the expected behaviour is the behaviour
     576        of ``facade = True``, unless the opposite can be deduced from the
     577        context (i.e. for instance if a
     578        :class:`~sage.combinat.posets.posets.FinitePoset` is built from another
     579        :class:`~sage.combinat.posets.posets.FinitePoset`, itself built with
     580        ``facade = False``)
    470581
    471582    - ``key`` -- any hashable value (default: ``None``).
    472583
     
    474585
    475586        sage: uc = [[2,3], [], [1], [1], [1], [3,4]]
    476587        sage: from sage.combinat.posets.posets import FinitePoset
    477         sage: P = FinitePoset(DiGraph(dict([[i,uc[i]] for i in range(len(uc))]))); P
     588        sage: P = FinitePoset(DiGraph(dict([[i,uc[i]] for i in range(len(uc))])), facade = False); P
    478589        Finite poset containing 6 elements
    479590        sage: P.cover_relations()
    480591        [[0, 2], [0, 3], [2, 1], [3, 1], [4, 1], [5, 3], [5, 4]]
     
    484595        sage: P.__class__
    485596        <class 'sage.combinat.posets.posets.FinitePoset_with_category'>
    486597
    487         sage: Q = sage.combinat.posets.posets.FinitePoset(P); Q
     598        sage: Q = sage.combinat.posets.posets.FinitePoset(P, facade = False); Q
    488599        Finite poset containing 6 elements
    489600
    490601        sage: Q is P
     
    492603
    493604    We keep the same underlying hasse diagram, but change the elements::
    494605
    495         sage: Q = sage.combinat.posets.posets.FinitePoset(P, elements=[1,2,3,4,5,6]); Q
     606        sage: Q = sage.combinat.posets.posets.FinitePoset(P, elements=[1,2,3,4,5,6], facade = False); Q
    496607        Finite poset containing 6 elements
    497608        sage: Q.cover_relations()
    498609        [[1, 3], [1, 4], [3, 2], [4, 2], [5, 2], [6, 4], [6, 5]]
    499610
    500611    We test the facade argument::
    501612
    502         sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}))
     613        sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}), facade = False)
    503614        sage: P.category()
    504615        Category of finite posets
    505616        sage: parent(P[0]) is P
     
    611722            if elements is None:
    612723                elements = hasse_diagram.vertices()
    613724            if facade is None:
    614                 facade = False
     725                facade = True
    615726        elements = tuple(elements)
    616727        category = Category.join([FinitePosets().or_subcategory(category), FiniteEnumeratedSets()])
    617728        return super(FinitePoset, cls).__classcall__(cls, hasse_diagram = hasse_diagram, elements = elements,
     
    621732        """
    622733        EXAMPLES::
    623734
    624             sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}))
     735            sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}), facade = False)
    625736            sage: type(P)
    626737            <class 'sage.combinat.posets.posets.FinitePoset_with_category'>
    627738
     
    680791
    681792        EXAMPLES::
    682793
    683             sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}))
     794            sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}), facade = False)
    684795            sage: L = P._list; L
    685796            (a, b, c, d)
    686797            sage: type(L[0])
     
    724835
    725836        TESTS::
    726837
    727             sage: P = Poset((divisors(15), attrcall("divides")))
     838            sage: P = Poset((divisors(15), attrcall("divides")), facade = False)
    728839
    729840        Testing for wrapped elements::
    730841
     
    758869
    759870        EXAMPLES::
    760871
    761             sage: P = Poset((divisors(15), attrcall("divides")))
     872            sage: P = Poset((divisors(15), attrcall("divides")), facade = False)
    762873            sage: x = P._vertex_to_element(2)
    763874            sage: x
    764875            5
     
    784895
    785896        EXAMPLES::
    786897
    787             sage: P = Poset((divisors(15), attrcall("divides")))
     898            sage: P = Poset((divisors(15), attrcall("divides")), facade = False)
    788899            sage: x = P.an_element(); x
    789900            1
    790901            sage: x.parent()
     
    854965        EXAMPLES::
    855966
    856967            sage: from sage.combinat.posets.posets import FinitePoset
    857             sage: P = FinitePoset(DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}))
     968            sage: P = FinitePoset(DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}), facade = False)
    858969            sage: P(5)
    859970            5
    860             sage: Q = FinitePoset(DiGraph({5:[2,3], 1:[3,4], 2:[0], 3:[0], 4:[0]}))
     971            sage: Q = FinitePoset(DiGraph({5:[2,3], 1:[3,4], 2:[0], 3:[0], 4:[0]}), facade = False)
    861972            sage: Q(5)
    862973            5
    863974
     
    869980            True
    870981            sage: Q(5) == Q(-1)
    871982            True
    872             sage: R = FinitePoset(DiGraph({'a':['b','c'], 'b':['d'], 'c':['d'], 'd':[]}))
     983            sage: R = FinitePoset(DiGraph({'a':['b','c'], 'b':['d'], 'c':['d'], 'd':[]}), facade = False)
    873984            sage: R(0)
    874985            a
    875986            sage: R('a') == R(0)
     
    886997
    887998        TESTS::
    888999
    889             sage: P = Poset(DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}))
     1000            sage: P = Poset(DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}), facade = False)
    8901001            sage: all(P(x) is x for x in P)
    8911002            True
    8921003            sage: P = Poset((divisors(15), attrcall("divides")), facade = True)
     
    9411052
    9421053        EXAMPLES::
    9431054
    944             sage: Q = Poset({5:[2,3], 1:[3,4], 2:[0], 3:[0], 4:[0]})
     1055            sage: Q = Poset({5:[2,3], 1:[3,4], 2:[0], 3:[0], 4:[0]}, facade = False)
    9451056            sage: Q.hasse_diagram()
    9461057            Digraph on 6 vertices
    9471058
    948             sage: P = Poset({'a':['b'],'b':['d'],'c':['d'],'d':['f'],'e':['f'],'f':[]})
     1059            sage: P = Poset({'a':['b'],'b':['d'],'c':['d'],'d':['f'],'e':['f'],'f':[]}, facade = False)
    9491060            sage: H = P.hasse_diagram()
    9501061            sage: P.cover_relations()
    9511062            [[e, f], [c, d], [a, b], [b, d], [d, f]]
    9521063            sage: H.edges()
    9531064            [(a, b, None), (c, d, None), (b, d, None), (e, f, None), (d, f, None)]
    9541065
    955             sage: P = Poset((divisors(15), attrcall("divides")))
     1066            sage: P = Poset((divisors(15), attrcall("divides")), facade = False)
    9561067            sage: H = P.hasse_diagram()
    9571068            sage: H.vertices()
    9581069            [1, 5, 3, 15]
     
    10881199
    10891200        INPUT:
    10901201
    1091         - ``facade`` -- a boolean (default: False);
     1202        - ``facade`` -- a boolean (default: ``False``);
    10921203          whether to return the linear extensions as plain lists
    10931204
     1205          .. warning::
     1206
     1207            The ``facade`` option is not yet fully functional::
     1208
     1209                sage: P = Poset((divisors(12), attrcall("divides")), linear_extension=True)
     1210                sage: L = P.linear_extensions(facade=True); L
     1211                The set of all linear extensions of Finite poset containing 6 elements
     1212                sage: L([1, 2, 3, 4, 6, 12])
     1213                Traceback (most recent call last):
     1214                ...
     1215                TypeError: Cannot convert list to sage.structure.element.Element
     1216
    10941217        .. seealso:: :meth:`linear_extension`, :meth:`is_linear_extension`
    10951218
    10961219        EXAMPLES::
     
    11301253                sage: type(L[0])
    11311254                <type 'list'>
    11321255
    1133         .. todo::
    1134 
    1135             The ``facade`` option is not yet fully functional::
    1136 
    1137                  sage: L = P.linear_extensions(facade=True); L
    1138                  The set of all linear extensions of Finite poset containing 6 elements
    1139                  sage: L([1, 2, 3, 4, 6, 12])
    1140                  Traceback (most recent call last):
    1141                  ...
    1142                  TypeError: Cannot convert list to sage.structure.element.Element
    1143 
    11441256        TESTS::
    11451257
    11461258            sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] })
     
    11891301       
    11901302        EXAMPLES::
    11911303       
    1192             sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] })
     1304            sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] }, facade = False)
    11931305            sage: D.list()
    11941306            [0, 1, 2, 3, 4]
    11951307            sage: type(D.list()[0])
     
    14041516
    14051517    def is_lequal(self, x, y):
    14061518        """
    1407         Returns True if x is less than or equal to y in the poset, and
    1408         False otherwise.
     1519        Returns ``True`` if `x` is less than or equal to `y` in the poset, and
     1520        ``False`` otherwise.
    14091521       
    14101522        EXAMPLES::
    14111523       
     
    14281540
    14291541    def is_less_than(self, x, y):
    14301542        """
    1431         Returns True if x is less than but not equal to y in the poset, and False
    1432         otherwise.
     1543        Returns ``True`` if `x` is less than but not equal to `y` in the poset,
     1544        and ``False`` otherwise.
    14331545
    14341546        EXAMPLES::
    14351547       
     
    14511563
    14521564    def is_gequal(self, x, y):
    14531565        """
    1454         Returns True if x is greater than or equal to y in the poset, and
    1455         False otherwise.
     1566        Returns ``True`` if `x` is greater than or equal to `y` in the poset,
     1567        and ``False`` otherwise.
    14561568       
    14571569        EXAMPLES::
    14581570       
     
    14771589
    14781590    def is_greater_than(self, x, y):
    14791591        """
    1480         Returns True if ``x`` is greater than but not equal to ``y``
    1481         in the poset, and False otherwise.
     1592        Returns ``True`` if `x` is greater than but not equal to `y` in the
     1593        poset, and ``False`` otherwise.
    14821594
    14831595        EXAMPLES::
    14841596       
     
    15021614
    15031615    def compare_elements(self, x, y):
    15041616        r"""
    1505         Compare ``x`` and ``y`` in the poset.
     1617        Compare `x` and `y` in the poset.
    15061618
    15071619        If ``x`` = ``y``, then ``0`` is returned;
    15081620        if ``x`` < ``y``, then ``-1`` is returned;
     
    17321844       
    17331845        EXAMPLES::
    17341846       
    1735             sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]])
     1847            sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade = False)
    17361848            sage: P.rank(5)
    17371849            2
    17381850            sage: P.rank()
     
    17421854            sage: P = Posets.SymmetricGroupBruhatOrderPoset(4)
    17431855       
    17441856            sage: [(v,P.rank(v)) for v in P]
    1745             [(1234, 0),
    1746              (1324, 1),
     1857            [('1234', 0),
     1858             ('1324', 1),
    17471859            ...
    1748              (4231, 5),
    1749              (4321, 6)]
     1860             ('4231', 5),
     1861             ('4321', 6)]
    17501862        """
    17511863        if element is None:
    17521864            return len(self.level_sets())-1
     
    19912103
    19922104        EXAMPLES::
    19932105
    1994             sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]])
     2106            sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade = False)
    19952107            sage: LEQM = P.lequal_matrix(); LEQM
    19962108            [1 1 1 1 1 1 1 1]
    19972109            [0 1 0 1 0 0 0 1]
     
    20542166
    20552167        EXAMPLES::
    20562168
    2057             sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]])
     2169            sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade = False)
    20582170            sage: M = P.meet_matrix(); M
    20592171            [0 0 0 0 0 0 0 0]
    20602172            [0 1 0 1 0 0 0 1]
     
    20792191
    20802192        EXAMPLES::
    20812193
    2082             sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]])
     2194            sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade = False)
    20832195            sage: P.is_meet_semilattice()
    20842196            True
    20852197
     
    21012213
    21022214        EXAMPLES::
    21032215
    2104             sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]])
     2216            sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade = False)
    21052217            sage: J = P.join_matrix(); J
    21062218            [0 1 2 3 4 5 6 7]
    21072219            [1 1 3 3 7 7 7 7]
     
    23552467
    23562468        EXAMPLES::
    23572469
    2358             sage: P = Poset((divisors(12), attrcall("divides")), linear_extension=True)
     2470            sage: P = Poset((divisors(12), attrcall("divides")), linear_extension=True, facade = False)
    23592471            sage: P.list()
    23602472            [1, 2, 3, 4, 6, 12]
    23612473            sage: P.cover_relations()
     
    23692481        Here we relabel the elements of a poset by {0,1,2, ...}, using
    23702482        a dictionary::
    23712483
    2372             sage: P = Poset((divisors(12), attrcall("divides")), linear_extension=True)
     2484            sage: P = Poset((divisors(12), attrcall("divides")), linear_extension=True, facade = False)
    23732485            sage: relabelling = {c.element:i for (i,c) in enumerate(P)}; relabelling
    23742486            {1: 0, 2: 1, 3: 2, 4: 3, 6: 4, 12: 5}
    23752487            sage: Q = P.relabel(relabelling)
     
    24962608
    24972609        EXAMPLES::
    24982610
    2499             sage: P = Poset({"a":["c","d"], "b":["d","e"], "c":["f"], "d":["f"], "e":["f"]})
     2611            sage: P = Poset({"a":["c","d"], "b":["d","e"], "c":["f"], "d":["f"], "e":["f"]}, facade = False)
    25002612            sage: Q = P.subposet(["a","b","f"]); Q
    25012613            Finite poset containing 3 elements
    25022614            sage: Q.cover_relations()
     
    25122624
    25132625        One may specified wrapped elements or not::
    25142626
    2515             sage: P = Poset({"a":["c","d"], "b":["d","e"], "c":["f"], "d":["f"], "e":["f"]})
     2627            sage: P = Poset({"a":["c","d"], "b":["d","e"], "c":["f"], "d":["f"], "e":["f"]}, facade = False)
    25162628            sage: Q = P.subposet([P("a"),P("b"),P("f")]); Q
    25172629            Finite poset containing 3 elements
    25182630            sage: Q.cover_relations()
     
    26272739        ::
    26282740
    26292741            sage: dg = DiGraph({"a":["b","c"], "b":["d"], "c":["d"]})
    2630             sage: P = Poset(dg)
     2742            sage: P = Poset(dg, facade = False)
    26312743            sage: P.interval("a","d")
    26322744            [a, c, b, d]
    26332745        """
     
    26692781        ::
    26702782
    26712783            sage: dg = DiGraph({"a":["b","c"], "b":["d"], "c":["d"]})
    2672             sage: P = Poset(dg)
     2784            sage: P = Poset(dg, facade = False)
    26732785            sage: P.open_interval("a","d")
    26742786            [c, b]
    26752787        """
     
    28102922
    28112923        EXAMPLES::
    28122924
    2813             sage: P = Poset(([1,2], [[1,2]]))
     2925            sage: P = Poset(([1,2], [[1,2]]), facade = False)
    28142926            sage: P.promotion()
    28152927            Finite poset containing 2 elements
    28162928            sage: P == P.promotion()
     
    28953007
    28963008        EXAMPLES::
    28973009
    2898             sage: P = Poset(([1,2], [[1,2]]))
     3010            sage: P = Poset(([1,2], [[1,2]]), facade = False)
    28993011            sage: P.evacuation()
    29003012            Finite poset containing 2 elements
    29013013            sage: P.evacuation() == P
    29023014            True
    29033015
    2904             sage: P = Poset(([1,2,3,4,5,6,7], [[1,2],[1,4],[2,3],[2,5],[3,6],[4,7],[5,6]]), linear_extension = True)
     3016            sage: P = Poset(([1,2,3,4,5,6,7], [[1,2],[1,4],[2,3],[2,5],[3,6],[4,7],[5,6]]), linear_extension = True, facade = False)
    29053017            sage: P.list()
    29063018            [1, 2, 3, 4, 5, 6, 7]
    29073019            sage: Q = P.evacuation(); Q
  • sage/combinat/root_system/associahedron.py

    diff --git a/sage/combinat/root_system/associahedron.py b/sage/combinat/root_system/associahedron.py
    a b  
    3232
    3333    An Associahedron
    3434
    35     The generalized associahedron is a polytopal complex with vertices
    36     in one-to-one correspondence with clusters in the cluster complex,
    37     and with edges between two vertices if and only if the associated
    38     two clusters intersect in codimension 1.
     35    The generalized associahedron is a polytopal complex with vertices in
     36    one-to-one correspondence with clusters in the cluster complex, and with
     37    edges between two vertices if and only if the associated two clusters
     38    intersect in codimension 1.
    3939
    40     The associahedron of type `A_n` is one way to realize the
    41     classical associahedron as defined in
     40    The associahedron of type `A_n` is one way to realize the classical
     41    associahedron as defined in :wikipedia:`Associahedron`
    4242
    43     http://en.wikipedia.org/wiki/Associahedron.
    44 
    45     A polytopal realization of the associahedron can be found in [CFZ].
    46     The implementation is based on [CFZ, Theorem 1.5, Remark 1.6, and Corollary 1.9.].
     43    A polytopal realization of the associahedron can be found in [CFZ].  The
     44    implementation is based on [CFZ, Theorem 1.5, Remark 1.6, and Corollary
     45    1.9.].
    4746
    4847    EXAMPLES::
    4948
  • sage/geometry/polyhedron/base.py

    diff --git a/sage/geometry/polyhedron/base.py b/sage/geometry/polyhedron/base.py
    a b  
    270270
    271271        face_lattice = self.face_lattice()
    272272        for face in face_lattice:
    273             Vrep = face.element.ambient_Vrepresentation()
     273            Vrep = face.ambient_Vrepresentation()
    274274            if len(Vrep) == 2:
    275275                set_adjacent(Vrep[0], Vrep[1])
    276276