Ticket #13566: 13566cna.patch

File 13566cna.patch, 3.8 KB (added by cnassau, 7 years ago)

make examples unique using @cached_method

  • sage/homology/examples.py

    # HG changeset patch
    # User Christian Nassau <nassau@nullhomotopie.de>
    # Date 1354972828 -3600
    # Node ID d74a5442d3991e3acadade1497bf66f301dc095b
    # Parent  e921acb11e4e0bff497fca555d4e5d87a5dff0b8
    [mq]: 13566
    
    diff --git a/sage/homology/examples.py b/sage/homology/examples.py
    a b  
    5252from sage.misc.functional import is_even
    5353from sage.combinat.subset import Subsets
    5454import sage.misc.prandom as random
     55from sage.misc.cachefunc import cached_method
    5556
    5657def matching(A, B):
    5758    """
     
    124125        {0: 0, 1: Z^16, 2: 0}
    125126    """
    126127
     128    @cached_method
    127129    def Sphere(self,n):
    128130        """
    129131        A minimal triangulation of the n-dimensional sphere.
     
    153155        S = SimplicialComplex(n+1, facets)
    154156        return S
    155157
     158    @cached_method
    156159    def Simplex(self, n):
    157160        """
    158161        An `n`-dimensional simplex, as a simplicial complex.
     
    175178        return SimplicialComplex(n, list(S))
    176179       
    177180
     181    @cached_method
    178182    def Torus(self):
    179183        """
    180184        A minimal triangulation of the torus.
     
    189193                                     [2,3,6], [0,2,6], [0,3,4], [0,3,5],
    190194                                     [4,5,6], [0,4,6]])
    191195
     196    @cached_method
    192197    def RealProjectivePlane(self):
    193198        """
    194199        A minimal triangulation of the real projective plane.
     
    214219
    215220    ProjectivePlane = RealProjectivePlane
    216221
     222    @cached_method
    217223    def KleinBottle(self):
    218224        """
    219225        A triangulation of the Klein bottle, formed by taking the
     
    228234        P = simplicial_complexes.RealProjectivePlane()
    229235        return P.connected_sum(P)
    230236
     237    @cached_method
    231238    def SurfaceOfGenus(self, g, orientable=True):
    232239        """
    233240        A surface of genus g.
     
    269276            S = S.connected_sum(T)
    270277        return S
    271278
     279    @cached_method
    272280    def MooreSpace(self, q):
    273281        """
    274282        Triangulation of the mod q Moore space.
     
    327335            facets.append(["A0", Ai, Aiplus])
    328336        return SimplicialComplex(vertices, facets)
    329337
     338    @cached_method
    330339    def ComplexProjectivePlane(self):
    331340        """
    332341        A minimal triangulation of the complex projective plane.
     
    363372             [8, 9, 3, 1, 6], [9, 7, 1, 2, 4], [7, 8, 2, 3, 5],
    364373             [9, 7, 2, 3, 6], [7, 8, 3, 1, 4], [8, 9, 1, 2, 5]])
    365374
     375    @cached_method
    366376    def PoincareHomologyThreeSphere(self):
    367377        """
    368378        A triangulation of the Poincare homology 3-sphere.
     
    411421             [9, 14, 15, 16], [10, 11, 13, 16], [10, 13, 15, 16],
    412422             [11, 13, 14, 16], [12, 13, 14, 15], [13, 14, 15, 16]])
    413423
     424    @cached_method
    414425    def RealProjectiveSpace(self, n):
    415426        r"""
    416427        A triangulation of `\Bold{R}P^n` for any `n \geq 0`.
     
    581592                facets.add(tuple(new))
    582593            return SimplicialComplex(list(facets))
    583594
     595    @cached_method
    584596    def K3Surface(self):
    585597        """
    586598        Returns a minimal triangulation of the K3 surface. This is
     
    613625    ###############################################################
    614626    # examples from graph theory:
    615627
     628    @cached_method
    616629    def NotIConnectedGraphs(self, n, i):
    617630        """
    618631        The simplicial complex of all graphs on n vertices which are
     
    681694                    facets.append(facet)
    682695        return SimplicialComplex(E_list, facets)
    683696               
     697    @cached_method
    684698    def MatchingComplex(self, n):
    685699        """
    686700        The matching complex of graphs on n vertices.
     
    770784                        facets.append(facet)
    771785        return SimplicialComplex(E_list, facets)
    772786               
     787    @cached_method
    773788    def ChessboardComplex(self, n, i):
    774789        r"""
    775790        The chessboard complex for an n by i chessboard.