Ticket #7634: trac_7634-switchover.patch

File trac_7634-switchover.patch, 15.7 KB (added by rlm, 13 years ago)

depends on 4.3.1.alpha1

  • sage/categories/examples/finite_semigroups.py

    # HG changeset patch
    # User Robert Miller <rlm@rlmiller.org>
    # Date 1245326234 25200
    # Node ID bab4423082321b85db61bc0e17f6f068d7787c06
    # Parent  afe90cf65c0ebc94601de63ab6b1c44e8a29c872
    Patch to switch the default implementation to c_graphs
    
    diff -r afe90cf65c0e -r bab442308232 sage/categories/examples/finite_semigroups.py
    a b  
    7373        sage: S = FiniteSemigroups().example(alphabet = ('a','b','c'))
    7474        sage: S.cayley_graph(side="left", simple=True).plot()
    7575        sage: S.j_transversal_of_idempotents()
    76         ['cab', 'ca', 'ab', 'cb', 'a', 'c', 'b']
     76        ['acb', 'ac', 'ab', 'bc', 'a', 'c', 'b']
    7777
    7878    We conclude by running systematic tests on this semigroup::
    7979
  • sage/categories/finite_semigroups.py

    diff -r afe90cf65c0e -r bab442308232 sage/categories/finite_semigroups.py
    a b  
    261261
    262262                sage: S = FiniteSemigroups().example(alphabet=('a','b', 'c'))
    263263                sage: S.j_classes()
    264                 [['cab', 'acb', 'bac', 'cba', 'bca', 'abc'], ['ca', 'ac'],
    265                 ['ab', 'ba'], ['cb', 'bc'], ['a'], ['c'], ['b']]
     264                [['acb', 'cab', 'bca', 'abc', 'bac', 'cba'], ['ac', 'ca'],
     265                ['ab', 'ba'], ['bc', 'cb'], ['a'], ['c'], ['b']]
    266266
    267267            """
    268268            return self.cayley_graph(side="twosided", simple=True).strongly_connected_components()
     
    295295
    296296                sage: S = FiniteSemigroups().example(alphabet=('a','b', 'c'))
    297297                sage: sorted(S.j_transversal_of_idempotents())
    298                 ['a', 'ab', 'b', 'c', 'ca', 'cab', 'cb']
     298                ['a', 'ab', 'ac', 'acb', 'b', 'bc', 'c']
    299299            """
    300300            def first_idempotent(l):
    301301                for x in l:
  • sage/combinat/posets/posets.py

    diff -r afe90cf65c0e -r bab442308232 sage/combinat/posets/posets.py
    a b  
    951951       
    952952            sage: [(v,P.rank(v)) for v in P]
    953953            [(1234, 0),
    954              (2134, 1),
     954             (1243, 1),
    955955            ...
    956              (4231, 5),
     956             (4312, 5),
    957957             (4321, 6)]
    958958        """
    959959        if element is None:
  • sage/combinat/yang_baxter_graph.py

    diff -r afe90cf65c0e -r bab442308232 sage/combinat/yang_baxter_graph.py
    a b  
    258258            sage: from sage.combinat.yang_baxter_graph import SwapIncreasingOperator
    259259            sage: ops = [SwapIncreasingOperator(i) for i in range(4)]
    260260            sage: Y = YangBaxterGraph(root=(1,0,2,1,0), operators=ops)
    261             sage: list(Y.__iter__())
    262             [(2, 1, 1, 0, 0), (1, 0, 2, 1, 0), (2, 1, 0, 1, 0), (1, 2, 1, 0, 0), (1, 2, 0, 1, 0)]
     261            sage: uniq(Y.__iter__())
     262            [(1, 0, 2, 1, 0), (1, 2, 0, 1, 0), (1, 2, 1, 0, 0), (2, 1, 0, 1, 0), (2, 1, 1, 0, 0)]
    263263        """
    264264        return self._digraph.vertex_iterator()
    265265
  • sage/graphs/base/sparse_graph.pyx

    diff -r afe90cf65c0e -r bab442308232 sage/graphs/base/sparse_graph.pyx
    a b  
    14891489        cdef int l_int = check_edge_label(l, self.edge_labels)
    14901490        if l_int not in self.edge_labels:
    14911491            return
     1492        if l_int == 0:
     1493            l_int = self._cg.arc_label(u_int, v_int)
    14921494        if directed:
    14931495            self._cg.del_arc_label(u_int, v_int, l_int)
    14941496            self._cg_rev.del_arc_label(v_int, u_int, l_int)
     
    15101512            sage: D.add_edges([(0,1,1), (2,3,2), (4,5,3), (5,6,2)], False)
    15111513            sage: list(D.iterator_edges(range(9), True))
    15121514            [(0, 1, 1), (2, 3, 2), (4, 5, 3), (5, 6, 2)]
    1513             sage: D.del_edge(0,1,None,True)
     1515            sage: D.del_edge(0,1,None,True) # "None" is equivalent to not providing a label
    15141516            sage: list(D.iterator_edges(range(9), True))
    1515             [(0, 1, 1), (2, 3, 2), (4, 5, 3), (5, 6, 2)]
    1516             sage: D.get_edge_label(1,0)
    1517             1
     1517            [(2, 3, 2), (4, 5, 3), (5, 6, 2)]
     1518            sage: D.get_edge_label(3,2)
     1519            2
    15181520
    15191521        """
    15201522        cdef int l_int
  • sage/graphs/graph.py

    diff -r afe90cf65c0e -r bab442308232 sage/graphs/graph.py
    a b  
    793793
    794794    ### Formats
    795795
    796     def copy(self, implementation='networkx', sparse=None):
     796    def copy(self, implementation='c_graph', sparse=None):
    797797        """
    798798        Creates a copy of the graph.
    799799
     
    22502250            sage: g=graphs.PetersenGraph()
    22512251            sage: o=g.eulerian_orientation()
    22522252            sage: o.in_degree()
    2253             [2, 2, 2, 2, 1, 2, 1, 1, 1, 1]
     2253            [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]
    22542254            sage: o.out_degree()
    2255             [1, 1, 1, 1, 2, 1, 2, 2, 2, 2]
     2255            [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
    22562256        """
    22572257        from copy import copy
    22582258        g=copy(self)
     
    25482548       
    25492549            sage: g = graphs.PetersenGraph()
    25502550            sage: (g.is_planar(kuratowski=True))[1].adjacency_matrix()
    2551             [0 1 0 0 0 1 0 0 0 0]
    2552             [1 0 1 0 0 0 1 0 0 0]
    2553             [0 1 0 1 0 0 0 0 0 0]
    2554             [0 0 1 0 1 0 0 0 1 0]
    2555             [0 0 0 1 0 0 0 0 0 1]
    2556             [1 0 0 0 0 0 0 1 1 0]
    2557             [0 1 0 0 0 0 0 0 1 1]
    2558             [0 0 0 0 0 1 0 0 0 1]
    2559             [0 0 0 1 0 1 1 0 0 0]
    2560             [0 0 0 0 1 0 1 1 0 0]
     2551            [0 1 0 0 0 1 0 0 0]
     2552            [1 0 1 0 0 0 1 0 0]
     2553            [0 1 0 1 0 0 0 1 0]
     2554            [0 0 1 0 0 0 0 0 1]
     2555            [0 0 0 0 0 0 1 1 0]
     2556            [1 0 0 0 0 0 0 1 1]
     2557            [0 1 0 0 1 0 0 0 1]
     2558            [0 0 1 0 1 1 0 0 0]
     2559            [0 0 0 1 0 1 1 0 0]
    25612560       
    25622561        ::
    25632562       
     
    52195218            sage: G = Graph()
    52205219            sage: G.add_edge((1,2), 'label')
    52215220            sage: G.edges()
    5222             [((1, 2), 'label', None)]
     5221            [('label', (1, 2), None)]
    52235222
    52245223        """
    52255224        if label is None:
     
    52705269       
    52715270        EXAMPLES::
    52725271       
    5273             sage: G = graphs.CompleteGraph(19)
     5272            sage: G = graphs.CompleteGraph(19).copy(implementation='c_graph')
    52745273            sage: G.size()
    52755274            171
    52765275            sage: G.delete_edge( 1, 2 )
     
    52825281        Note that NetworkX accidentally deletes these edges, even though the
    52835282        labels do not match up::
    52845283           
    5285             sage: G.delete_edge( 9, 10, 'label' )
    5286             sage: G.delete_edge( (11, 12, 'label') )
    5287             sage: G.delete_edges( [ (13, 14, 'label') ] )
    5288             sage: G.size()
     5284            sage: N = graphs.CompleteGraph(19).copy(implementation='networkx')
     5285            sage: N.size()
     5286            171
     5287            sage: N.delete_edge( 1, 2 )
     5288            sage: N.delete_edge( (3, 4) )
     5289            sage: N.delete_edges( [ (5, 6), (7, 8) ] )
     5290            sage: N.size()
     5291            167
     5292            sage: N.delete_edge( 9, 10, 'label' )
     5293            sage: N.delete_edge( (11, 12, 'label') )
     5294            sage: N.delete_edges( [ (13, 14, 'label') ] )
     5295            sage: N.size()
    52895296            164
    5290             sage: G.has_edge( (11, 12) )
     5297            sage: N.has_edge( (11, 12) )
    52915298            False
    52925299
    52935300        However, CGraph backends handle things properly::
    52945301       
    5295             sage: G = graphs.CompleteGraph(19).copy(implementation='c_graph')
    5296             sage: G.size()
    5297             171
    5298             sage: G.delete_edge( 1, 2 )
    5299             sage: G.delete_edge( (3, 4) )
    5300             sage: G.delete_edges( [ (5, 6), (7, 8) ] )
    53015302            sage: G.delete_edge( 9, 10, 'label' )
    53025303            sage: G.delete_edge( (11, 12, 'label') )
    53035304            sage: G.delete_edges( [ (13, 14, 'label') ] )
     
    53065307       
    53075308        ::
    53085309       
    5309             sage: D = graphs.CompleteGraph(19).to_directed(sparse=True)
     5310            sage: C = graphs.CompleteGraph(19).to_directed(sparse=True)
     5311            sage: C.size()
     5312            342
     5313            sage: C.delete_edge( 1, 2 )
     5314            sage: C.delete_edge( (3, 4) )
     5315            sage: C.delete_edges( [ (5, 6), (7, 8) ] )
     5316       
     5317        Again, NetworkX deleting edges when it shouldn't::
     5318       
     5319            sage: D = graphs.CompleteGraph(19).to_directed(sparse=True, implementation='networkx')
    53105320            sage: D.size()
    53115321            342
    53125322            sage: D.delete_edge( 1, 2 )
    53135323            sage: D.delete_edge( (3, 4) )
    53145324            sage: D.delete_edges( [ (5, 6), (7, 8) ] )
    5315             sage: C = D.copy(implementation='c_graph')
    5316        
    5317         Again, NetworkX deleting edges when it shouldn't::
    5318        
    53195325            sage: D.delete_edge( 9, 10, 'label' )
    53205326            sage: D.delete_edge( (11, 12, 'label') )
    53215327            sage: D.delete_edges( [ (13, 14, 'label') ] )
     
    60426048            2
    60436049            ...
    60446050            2
    6045             3
     6051            4
    60466052            sage: for i in G.degree_iterator(labels=True):
    60476053            ...    print i
    60486054            ((0, 1), 3)
     
    60506056            ((0, 0), 2)
    60516057            ...
    60526058            ((0, 3), 2)
    6053             ((0, 2), 3)
     6059            ((1, 1), 4)
    60546060       
    60556061        ::
    60566062       
     
    62716277            sage: C = graphs.CubeGraph(2)
    62726278            sage: S = C.subgraph(edge_property=(lambda e: e[0][0] == e[1][0]))
    62736279            sage: C.edges()
    6274             [('00', '01', None), ('10', '00', None), ('11', '01', None), ('11', '10', None)]
     6280            [('00', '01', None), ('00', '10', None), ('01', '11', None), ('10', '11', None)]
    62756281            sage: S.edges()
    6276             [('00', '01', None), ('11', '10', None)]
     6282            [('00', '01', None), ('10', '11', None)]
    62776283       
    62786284
    62796285        The algorithm is not specified, then a reasonable choice is made for speed.
     
    64076413            sage: C = graphs.CubeGraph(2)
    64086414            sage: S = C._subgraph_by_adding(vertices=C.vertices(), edge_property=(lambda e: e[0][0] == e[1][0]))
    64096415            sage: C.edges()
    6410             [('00', '01', None), ('10', '00', None), ('11', '01', None), ('11', '10', None)]
     6416            [('00', '01', None), ('00', '10', None), ('01', '11', None), ('10', '11', None)]
    64116417            sage: S.edges()
    6412             [('00', '01', None), ('11', '10', None)]
     6418            [('00', '01', None), ('10', '11', None)]
    64136419       
    64146420        TESTS: Properties of the graph are preserved.
    64156421       
     
    65526558            sage: C = graphs.CubeGraph(2)
    65536559            sage: S = C._subgraph_by_deleting(vertices=C.vertices(), edge_property=(lambda e: e[0][0] == e[1][0]))
    65546560            sage: C.edges()
    6555             [('00', '01', None), ('10', '00', None), ('11', '01', None), ('11', '10', None)]
     6561            [('00', '01', None), ('00', '10', None), ('01', '11', None), ('10', '11', None)]
    65566562            sage: S.edges()
    6557             [('00', '01', None), ('11', '10', None)]
     6563            [('00', '01', None), ('10', '11', None)]
    65586564       
    65596565        TESTS: Properties of the graph are preserved.
    65606566       
     
    1142011426    _directed = False
    1142111427   
    1142211428    def __init__(self, data=None, pos=None, loops=None, format=None,
    11423                  boundary=[], weighted=None, implementation='networkx',
     11429                 boundary=[], weighted=None, implementation='c_graph',
    1142411430                 sparse=True, vertex_labels=True, **kwds):
    1142511431        """
    1142611432        TESTS::
     
    1268212688   
    1268312689    ### Constructors
    1268412690
    12685     def to_directed(self, implementation='networkx', sparse=None):
     12691    def to_directed(self, implementation='c_graph', sparse=None):
    1268612692        """
    1268712693        Returns a directed version of the graph. A single edge becomes two
    1268812694        edges, one in each direction.
     
    1269312699            Petersen graph: Digraph on 10 vertices
    1269412700        """
    1269512701        if sparse is None:
    12696             from sage.graphs.base.sparse_graph import SparseGraphBackend
    12697             sparse = isinstance(self._backend, SparseGraphBackend)
     12702            from sage.graphs.base.dense_graph import DenseGraphBackend
     12703            sparse = (not isinstance(self._backend, DenseGraphBackend))
    1269812704        D = DiGraph(name=self.name(), pos=self._pos, boundary=self._boundary,
    1269912705                    multiedges=self.allows_multiple_edges(),
    1270012706                    implementation=implementation, sparse=sparse)
     
    1320913215            sage: for v in sorted(X.iterkeys()):
    1321013216            ...    print v, X[v]
    1321113217            (0, 0) [[(0, 1), (0, 0)], [(1, 0), (0, 0)]]
    13212             (0, 1) [[(0, 1), (0, 0)], [(0, 1), (0, 2)], [(0, 1), (1, 1)]]
     13218            (0, 1) [[(0, 1), (0, 0)], [(0, 1), (1, 1)], [(0, 1), (0, 2)]]
    1321313219            (0, 2) [[(0, 1), (0, 2)], [(1, 2), (0, 2)]]
    1321413220            (1, 0) [[(1, 0), (0, 0)], [(1, 0), (1, 1)]]
    1321513221            (1, 1) [[(0, 1), (1, 1)], [(1, 2), (1, 1)], [(1, 0), (1, 1)]]
    13216             (1, 2) [[(1, 2), (0, 2)], [(1, 2), (1, 1)]]
     13222            (1, 2) [[(1, 2), (1, 1)], [(1, 2), (0, 2)]]
    1321713223            sage: F.cliques_containing_vertex(vertices=[(0, 1), (1, 2)])
    13218             [[[(0, 1), (0, 0)], [(0, 1), (0, 2)], [(0, 1), (1, 1)]], [[(1, 2), (0, 2)], [(1, 2), (1, 1)]]]
     13224            [[[(0, 1), (0, 0)], [(0, 1), (1, 1)], [(0, 1), (0, 2)]], [[(1, 2), (1, 1)], [(1, 2), (0, 2)]]]
    1321913225            sage: G = Graph({0:[1,2,3], 1:[2], 3:[0,1]})
    1322013226            sage: G.show(figsize=[2,2])
    1322113227            sage: G.cliques_containing_vertex()
     
    1373813744    _directed = True
    1373913745
    1374013746    def __init__(self, data=None, pos=None, loops=None, format=None,
    13741                  boundary=[], weighted=None, implementation='networkx',
     13747                 boundary=[], weighted=None, implementation='c_graph',
    1374213748                 sparse=True, vertex_labels=True, **kwds):
    1374313749        """
    1374413750        TESTS::
     
    1415314159        from copy import copy
    1415414160        return copy(self)
    1415514161
    14156     def to_undirected(self, implementation='networkx', sparse=None):
     14162    def to_undirected(self, implementation='c_graph', sparse=None):
    1415714163        """
    1415814164        Returns an undirected version of the graph. Every directed edge
    1415914165        becomes an edge.
     
    1416814174            [(0, 1), (0, 2)]
    1416914175        """
    1417014176        if sparse is None:
    14171             from sage.graphs.base.sparse_graph import SparseGraphBackend
    14172             sparse = isinstance(self._backend, SparseGraphBackend)
     14177            from sage.graphs.base.dense_graph import DenseGraphBackend
     14178            sparse = (not isinstance(self._backend, DenseGraphBackend))
    1417314179        G = Graph(name=self.name(), pos=self._pos, boundary=self._boundary,
    1417414180                  multiedges=self.allows_multiple_edges(), loops=self.allows_loops(),
    1417514181                  implementation=implementation, sparse=sparse)
  • sage/homology/simplicial_complex.py

    diff -r afe90cf65c0e -r bab442308232 sage/homology/simplicial_complex.py
    a b  
    490490            sage: Simplex([0,1,2]) == Simplex(['a','b','c'])
    491491            False
    492492        """
    493         if self.__set == other.__set:
     493        if not isinstance(other, Simplex) or self.__set != other.__set:
     494            return -1
     495        else:
    494496            return 0
    495         else:
    496             return -1
    497497
    498498    def __hash__(self):
    499499        """
     
    20082008            sage: P = SimplicialComplex(3, [[0, 1], [1,2], [2,3]]).face_poset(); P
    20092009            Finite poset containing 7 elements
    20102010            sage: P.list()
    2011             [(3,), (2,), (2, 3), (1,), (0,), (0, 1), (1, 2)]
     2011            [(3,), (2,), (2, 3), (1,), (0,), (1, 2), (0, 1)]
    20122012        """
    20132013        from sage.combinat.posets.posets import Poset
    20142014        covers = {}