Ticket #13747: trac_13747-doctests.patch

File trac_13747-doctests.patch, 15.1 KB (added by ncohen, 8 years ago)
  • sage/categories/coxeter_groups.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1354453591 -3600
    # Node ID f62a40d61d1a3b9987b7de659bb9631718656186
    # Parent  5fbca18f0f90bcefcf1d37f87d6069855b63cc3c
    Change default behaviour of Poset to facade = True -- removing ".element" everywhere
    
    diff --git a/sage/categories/coxeter_groups.py b/sage/categories/coxeter_groups.py
    a b  
    14341434
    14351435                sage: W = WeylGroup(["B",3])
    14361436                sage: P = W.bruhat_poset() # This is built from bruhat_lower_covers
    1437                 sage: Q = Poset((W, attrcall("bruhat_le")))                         # long time (10s)
    1438                 sage: all( u.bruhat_le(v) == (P(u) <= P(v)) for u in W for v in W ) # long time  (7s)
     1437                sage: Q = Poset((W, attrcall("bruhat_le")))                             # long time (10s)
     1438                sage: all( u.bruhat_le(v) == P.is_lequal(u,v) for u in W for v in W ) # long time  (7s)
    14391439                True
    1440                 sage: all((P(u) <= P(v)) == (Q(u) <= Q(v)) for u in W for v in W)   # long time  (9s)
     1440                sage: all( P.is_lequal(u,v) == Q.is_lequal(u,v) for u in W for v in W)       # long time  (9s)
    14411441                True
    14421442
    14431443            """
  • sage/categories/finite_lattice_posets.py

    diff --git a/sage/categories/finite_lattice_posets.py b/sage/categories/finite_lattice_posets.py
    a b  
    110110
    111111                sage: D = LatticePoset((divisors(60), attrcall("divides")))
    112112                sage: B = LatticePoset((Subsets([2,2,3]), attrcall("issubset")))
    113                 sage: def f(b): return D(5*prod(b.element))
     113                sage: def f(b): return D(5*prod(b))
    114114                sage: B.is_lattice_morphism(f, D)
    115115                True
    116116
  • sage/categories/finite_posets.py

    diff --git a/sage/categories/finite_posets.py b/sage/categories/finite_posets.py
    a b  
    115115
    116116                sage: D = Poset((divisors(30), attrcall("divides")))
    117117                sage: B = Poset(([frozenset(s) for s in Subsets([2,3,5])], attrcall("issubset")))
    118                 sage: def f(b): return D(prod(b.element))
     118                sage: def f(b): return D(prod(b))
    119119                sage: B.is_poset_isomorphism(f, D)
    120120                True
    121121
     
    123123            of divisors of 30, ordered by usual comparison::
    124124
    125125                sage: P = Poset((divisors(30), operator.le))
    126                 sage: def f(b): return P(prod(b.element))
     126                sage: def f(b): return P(prod(b))
    127127                sage: B.is_poset_isomorphism(f, P)
    128128                False
    129129
    130130            A non surjective case::
    131131
    132132                sage: B = Poset(([frozenset(s) for s in Subsets([2,3])], attrcall("issubset")))
    133                 sage: def f(b): return D(prod(b.element))
     133                sage: def f(b): return D(prod(b))
    134134                sage: B.is_poset_isomorphism(f, D)
    135135                False
    136136
    137137            A non injective case::
    138138
    139139                sage: B = Poset(([frozenset(s) for s in Subsets([2,3,5,6])], attrcall("issubset")))
    140                 sage: def f(b): return D(gcd(prod(b.element), 30))
     140                sage: def f(b): return D(gcd(prod(b), 30))
    141141                sage: B.is_poset_isomorphism(f, D)
    142142                False
    143143
     
    180180
    181181                sage: D = Poset((divisors(30), attrcall("divides")))
    182182                sage: B = Poset(([frozenset(s) for s in Subsets([2,3,5,6])], attrcall("issubset")))
    183                 sage: def f(b): return D(gcd(prod(b.element), 30))
     183                sage: def f(b): return D(gcd(prod(b), 30))
    184184                sage: B.is_poset_morphism(f, D)
    185185                True
    186186
     
    192192            of 30, ordered by usual comparison::
    193193
    194194                sage: P = Poset((divisors(30), operator.le))
    195                 sage: def f(b): return P(gcd(prod(b.element), 30))
     195                sage: def f(b): return P(gcd(prod(b), 30))
    196196                sage: B.is_poset_morphism(f, P)
    197197                True
    198198
     
    206206
    207207                sage: P = Posets.ChainPoset(2)
    208208                sage: Q = Posets.AntichainPoset(2)
    209                 sage: f = lambda x: 1-x.element
     209                sage: f = lambda x: 1-x
    210210                sage: P.is_poset_morphism(f, P)
    211211                False
    212212                sage: P.is_poset_morphism(f, Q)
     
    338338
    339339                sage: P = Poset( ( [1,2,3], [ [1,3], [2,3] ] ) )
    340340                sage: P.panyushev_orbits()
    341                 [[set([3]), set([]), set([1, 2])], [set([2]), set([1])]]
     341                [[set([2]), set([1])], [set([]), set([1, 2]), set([3])]]
    342342            """
    343343            # TODO: implement a generic function taking a set and
    344344            # bijections on this set, and returning the orbits.
  • sage/categories/posets.py

    diff --git a/sage/categories/posets.py b/sage/categories/posets.py
    a b  
    5353    Unless the poset is a facade (see :class:`Sets.Facades`), one can
    5454    compare directly its elements using the usual Python operators::
    5555
    56         sage: D = Poset((divisors(30), attrcall("divides")))
     56        sage: D = Poset((divisors(30), attrcall("divides")), facade = False)
    5757        sage: D(3) <= D(6)
    5858        True
    5959        sage: D(3) <= D(3)
  • sage/geometry/cone.py

    diff --git a/sage/geometry/cone.py b/sage/geometry/cone.py
    a b  
    148148    sage: map(len, L.level_sets())
    149149    [1, 4, 4, 1]
    150150    sage: face = L.level_sets()[2][0]
    151     sage: face.element.rays()
     151    sage: face.rays()
    152152    N(1,  1, 1),
    153153    N(1, -1, 1)
    154154    in 3-d lattice N
     
    18051805                    adjacent.update(L.open_interval(facet,  superface))
    18061806            if adjacent:
    18071807                adjacent.remove(L(self))
    1808             return self._sort_faces(face.element for face in adjacent)
     1808            return self._sort_faces(iter(adjacent))
    18091809        elif self.dim() == self._ambient.dim():
    18101810            # Special treatment relevant for fans
    18111811            for facet in facets:
     
    21062106             1-d face of 2-d cone in 2-d lattice N]
    21072107            [2-d cone in 2-d lattice N]
    21082108
    2109         To work with a particular face of a particular dimension it is not
    2110         enough to do just ::
     2109        Now you can look at the rays of this face... ::
    21112110
    21122111            sage: face = L.level_sets()[1][0]
    2113             sage: face
    2114             1-d face of 2-d cone in 2-d lattice N
    2115             sage: face.rays()
    2116             Traceback (most recent call last):
    2117             ...
    2118             AttributeError: 'FinitePoset_with_category.element_class' object
    2119             has no attribute 'rays'
    2120 
    2121         To get the actual face you need one more step::
    2122 
    2123             sage: face = face.element
    2124 
    2125         Now you can look at the actual rays of this face... ::
    2126 
    21272112            sage: face.rays()
    21282113            N(1, 0)
    21292114            in 2-d lattice N
     
    21482133            sage: face = L.level_sets()[1][0]
    21492134            sage: D = L.hasse_diagram()
    21502135            sage: D.neighbors(face)
    2151             [0-d face of 2-d cone in 2-d lattice N,
    2152              2-d cone in 2-d lattice N]
     2136            [2-d cone in 2-d lattice N,
     2137             0-d face of 2-d cone in 2-d lattice N]
    21532138
    21542139        However, you can achieve some of this functionality using
    21552140        :meth:`facets`, :meth:`facet_of`, and :meth:`adjacent` methods::
     
    21882173            0-d face of 4-d cone in 4-d lattice N
    21892174            sage: cone.face_lattice().top()
    21902175            3-d face of 4-d cone in 4-d lattice N
    2191             sage: cone.face_lattice().top().element == cone
     2176            sage: cone.face_lattice().top() == cone
    21922177            True
    21932178
    21942179        TESTS::
     
    22652250                allowed_indices = frozenset(self._ambient_ray_indices)
    22662251                L = DiGraph()
    22672252                origin = \
    2268                     self._ambient._face_lattice_function().bottom().element
     2253                    self._ambient._face_lattice_function().bottom()
    22692254                L.add_vertex(0) # In case it is the only one
    22702255                dfaces = [origin]
    22712256                faces = [origin]
     
    24202405                    "dimension and codimension cannot be specified together!")
    24212406        dim = self.dim() - codim if codim is not None else dim
    24222407        if "_faces" not in self.__dict__:
    2423             self._faces = tuple(self._sort_faces(e.element for e in level)
     2408            self._faces = tuple(self._sort_faces(iter(level))
    24242409                                for level in self.face_lattice().level_sets())
    24252410            # To avoid duplication and ensure order consistency
    24262411            if len(self._faces) > 1:
     
    25652550        if "_facet_of" not in self.__dict__:
    25662551            L = self._ambient._face_lattice_function()
    25672552            H = L.hasse_diagram()
    2568             self._facet_of = self._sort_faces(f.element
    2569                     for f in H.neighbors_out(L(self)) if is_Cone(f.element))
     2553            self._facet_of = self._sort_faces(f
     2554                    for f in H.neighbors_out(L(self)) if is_Cone(f))
    25702555        return self._facet_of
    25712556
    25722557    def facets(self):
     
    25872572        if "_facets" not in self.__dict__:
    25882573            L = self._ambient._face_lattice_function()
    25892574            H = L.hasse_diagram()
    2590             self._facets = self._sort_faces(tuple(
    2591                                 f.element for f in H.neighbors_in(L(self))))
     2575            self._facets = self._sort_faces(tuple(H.neighbors_in(L(self))))
    25922576        return self._facets
    25932577
    25942578    def intersection(self, other):
     
    36073591            sage: rho = Cone([(1,1,1,3),(1,-1,1,3),(-1,-1,1,3),(-1,1,1,3)])
    36083592            sage: rho.orthogonal_sublattice()
    36093593            Sublattice <M(0, 0, 3, -1)>
    3610             sage: sigma = rho.facets()[1]
     3594            sage: sigma = rho.facets()[2]
    36113595            sage: sigma.orthogonal_sublattice()
    36123596            Sublattice <M(0, 1, 1, 0), M(0, 3, 0, 1)>
    36133597            sage: sigma.is_face_of(rho)
  • sage/geometry/fan.py

    diff --git a/sage/geometry/fan.py b/sage/geometry/fan.py
    a b  
    156156    sage: cone
    157157    2-d cone of Rational polyhedral fan in 3-d lattice N
    158158    sage: L.hasse_diagram().neighbors(cone)
    159     [3-d cone of Rational polyhedral fan in 3-d lattice N,
     159    [1-d cone of Rational polyhedral fan in 3-d lattice N,
    160160     3-d cone of Rational polyhedral fan in 3-d lattice N,
    161161     1-d cone of Rational polyhedral fan in 3-d lattice N,
    162      1-d cone of Rational polyhedral fan in 3-d lattice N]
    163 
    164 Note, that while ``cone`` above seems to be a "cone", it is not::
    165 
    166     sage: cone.rays()
    167     Traceback (most recent call last):
    168     ...
    169     AttributeError: 'FinitePoset_with_category.element_class' object
    170     has no attribute 'rays'
    171 
    172 To get your hands on the "real" cone, you need to do one more step::
    173 
    174     sage: cone = cone.element
    175     sage: cone.rays()
    176     N(1, 0, 0),
    177     N(0, 1, 0)
    178     in 3-d lattice N
     162     3-d cone of Rational polyhedral fan in 3-d lattice N]
    179163
    180164You can check how "good" a fan is::
    181165
     
    13131297                L_cone = Cone(cone.rays(), lattice=self.lattice(),
    13141298                              check=False, normalize=False).face_lattice()
    13151299                for f in L_cone:
    1316                     f = f.element
    13171300                    f_rays = tuple(cone.ambient_ray_indices()[ray]
    13181301                                   for ray in f.ambient_ray_indices())
    13191302                    face_to_rays[f] = f_rays
     
    13271310                        index_to_cones.append([i])
    13281311                # Add all relations between faces of cone to L
    13291312                for f,g in L_cone.cover_relations_iterator():
    1330                     L.add_edge(rays_to_index[face_to_rays[f.element]],
    1331                                rays_to_index[face_to_rays[g.element]])
     1313                    L.add_edge(rays_to_index[face_to_rays[f]],
     1314                               rays_to_index[face_to_rays[g]])
    13321315                # Add the inclusion of cone into the fan itself
    13331316                L.add_edge(
    1334                         rays_to_index[face_to_rays[L_cone.top().element]], 0)
     1317                        rays_to_index[face_to_rays[L_cone.top()]], 0)
    13351318
    13361319            # Enumeration of graph vertices must be a linear extension of the
    13371320            # poset
     
    18911874        largest face, you should be a little bit careful with this last
    18921875        element::
    18931876
    1894             sage: for face in L: print face.element.ambient_ray_indices()
     1877            sage: for face in L: print face.ambient_ray_indices()
    18951878            Traceback (most recent call last):
    18961879            ...
    18971880            AttributeError: 'RationalPolyhedralFan'
     
    19021885        For example, you can do ::
    19031886
    19041887            sage: for l in L.level_sets()[:-1]:
    1905             ...       print [f.element.ambient_ray_indices() for f in l]
     1888            ...       print [f.ambient_ray_indices() for f in l]
    19061889            [()]
    19071890            [(0,), (1,), (2,)]
    19081891            [(0, 1)]
     
    19141897            sage: fan = FaceFan(lattice_polytope.octahedron(2))
    19151898            sage: L = fan.cone_lattice()
    19161899            sage: for l in L.level_sets()[:-1]:
    1917             ...       print [f.element.ambient_ray_indices() for f in l]
     1900            ...       print [f.ambient_ray_indices() for f in l]
    19181901            [()]
    19191902            [(0,), (1,), (2,), (3,)]
    19201903            [(0, 1), (1, 2), (0, 3), (2, 3)]
     
    20021985            (2-d cone of Rational polyhedral fan in 2-d lattice N,)
    20031986           
    20041987        You cannot specify both dimension and codimension, even if they
    2005         "agree"::
     1988        'agree'::
    20061989       
    20071990            sage: fan(dim=1, codim=1)
    20081991            Traceback (most recent call last):
     
    20202003            ()
    20212004        """
    20222005        if "_cones" not in self.__dict__:
    2023             levels = [(e.element for e in level) # Generators
    2024                       for level in self.cone_lattice().level_sets()]
     2006            levels = map(iter,self.cone_lattice().level_sets()) # generators
     2007
    20252008            levels.pop() # The very last level is this FAN, not cone.
    20262009            # It seems that there is no reason to believe that the order of
    20272010            # faces in level sets has anything to do with the order of
  • sage/geometry/polyhedron/base.py

    diff --git a/sage/geometry/polyhedron/base.py b/sage/geometry/polyhedron/base.py
    a b  
    239239
    240240        face_lattice = self.face_lattice()
    241241        for face in face_lattice:
    242             Hrep = face.element.ambient_Hrepresentation()
     242            Hrep = face.ambient_Hrepresentation()
    243243            if len(Hrep) == 2:
    244244                set_adjacent(Hrep[0], Hrep[1])
    245245        return M
     
    22972297            sage: list(_)
    22982298            [<>, <0>, <1>, <2>, <3>, <0,1>, <0,2>, <2,3>, <1,3>, <0,1,2,3>]
    22992299            sage: poset_element = _[6]
    2300             sage: a_face = poset_element.element
     2300            sage: a_face = poset_element
    23012301            sage: a_face
    23022302            <0,2>
    23032303            sage: a_face.dim()
     
    23222322        face in the face lattice::
    23232323
    23242324            sage: line = Polyhedron(vertices=[(0,)], lines=[(1,)])
    2325             sage: [ fl.element.dim() for fl in line.face_lattice() ]
     2325            sage: [ fl.dim() for fl in line.face_lattice() ]
    23262326            [-1, 1]
    23272327
    23282328        TESTS::