Ticket #10900: trac_10900-part2.patch

File trac_10900-part2.patch, 7.3 KB (added by rlm, 10 years ago)
  • sage/graphs/base/dense_graph.pyx

    # HG changeset patch
    # User Robert L. Miller <rlm@rlmiller.org>
    # Date 1299797410 28800
    # Node ID c25879359da3984b4d46a9a6cacf7300758a59bc
    # Parent  59bc745f1cf1b081c82889fdf101f4e52213a189
    #10900 - last four doctests to bring sage/graphs coverage back up to 100%
    
    diff -r 59bc745f1cf1 -r c25879359da3 sage/graphs/base/dense_graph.pyx
    a b  
    213213        bitset_free(self.active_vertices)
    214214
    215215    def __reduce__(self):
     216        """
     217        Return a tuple used for pickling this graph.
     218       
     219        TESTS::
     220
     221            sage: from sage.graphs.base.dense_graph import DenseGraph
     222            sage: D = DenseGraph(nverts = 10, extra_vertices = 10)
     223            sage: D.add_arc(0,1)
     224            sage: D.has_arc(0,1)
     225            1
     226            sage: D.has_arc(1,2)
     227            0
     228            sage: LD = loads(dumps(D))
     229            sage: LD.has_arc(0,1)
     230            1
     231            sage: LD.has_arc(1,2)
     232            0
     233
     234        """
    216235        from sage.graphs.all import DiGraph
    217236        D = DiGraph(implementation='c_graph', sparse=False)
    218237        D._backend._cg = self
  • sage/graphs/base/graph_backends.py

    diff -r 59bc745f1cf1 -r c25879359da3 sage/graphs/base/graph_backends.py
    a b  
    473473    """
    474474    Class for unpickling old networkx.XGraph formats
    475475
    476     DOCTEST:
    477         sage: import sage.graphs.base.graph_backends
     476    DOCTEST::
     477
     478        sage: from sage.graphs.base.graph_backends import NetworkXGraphDeprecated as NXGD
     479        sage: X = NXGD()
     480        doctest:...
     481       
    478482    """
    479483
    480484    def __init__(self):
     
    490494        """
    491495        import warnings
    492496        from sage.misc.misc import deprecation
    493         warnings.warn("Your graph object is saved in an old format since networkx\
    494                     was updated to 1.0.1. You can re-save your graph by typing\
    495                     graph.save(filename) to make this warning go away.",
    496                     DeprecationWarning, stacklevel=2)
    497         deprecation("Your graph object is saved in an old format since networkx\
    498                     was updated to 1.0.1. You can re-save your graph by typing\
    499                     graph.save(filename) to make this warning go away.")
     497        warnings.warn("Your graph object is saved in an old format since networkx "+
     498                      "was updated to 1.0.1. You can re-save your graph by typing "+
     499                      "graph.save(filename) to make this warning go away.",
     500                      DeprecationWarning, stacklevel=2)
     501        deprecation("Your graph object is saved in an old format since networkx "+
     502                    "was updated to 1.0.1. You can re-save your graph by typing "+
     503                    "graph.save(filename) to make this warning go away.")
    500504
    501505    def mutate(self):
    502506        """
     
    506510
    507511        - The networkx.Graph or networkx.MultiGraph corresponding to the
    508512          unpickled data.
     513
     514        EXAMPLES::
     515
     516            sage: from sage.graphs.base.graph_backends import NetworkXGraphDeprecated as NXGD
     517            sage: X = NXGD()
     518            doctest:...
     519            sage: X.adj = {1:{2:7}, 2:{1:7}, 3:{2:[4,5,6,7]}, 2:{3:[4,5,6,7]}}
     520            sage: X.multiedges = True
     521            sage: G = X.mutate()
     522            sage: G.edges()
     523            [(1, 2), (2, 3)]
     524            sage: G.edges(data=True)
     525            [(1, 2, {'weight': 7}), (2, 3, {4: {}, 5: {}, 6: {}, 7: {}})]
     526
    509527        """
    510528        import networkx
    511529        new_adj = {}
     
    519537                        for weight in weights:
    520538                            new_adj[node1][node2][weight] = {}
    521539                    except TypeError:
    522                         new_adj[node1][node2]['weight'] = weight
     540                        new_adj[node1][node2]['weight'] = weights
    523541
    524542        if self.multiedges:
    525543            G = networkx.MultiGraph(new_adj)
     
    549567        """
    550568        import warnings
    551569        from sage.misc.misc import deprecation
    552         warnings.warn("Your digraph object is saved in an old format since networkx\
    553                     was updated to 1.0.1. You can re-save your digraph by typing\
    554                     digraph.save(filename) to make this warning go away.",
    555                     DeprecationWarning, stacklevel=2)
    556         deprecation("Your digraph object is saved in an old format since networkx\
    557                     was updated to 1.0.1. You can re-save your digraph by typing\
    558                     digraph.save(filename) to make this warning go away.")
     570        warnings.warn("Your digraph object is saved in an old format since networkx "+
     571                      "was updated to 1.0.1. You can re-save your digraph by typing "+
     572                      "digraph.save(filename) to make this warning go away.",
     573                      DeprecationWarning, stacklevel=2)
     574        deprecation("Your digraph object is saved in an old format since networkx "+
     575                    "was updated to 1.0.1. You can re-save your digraph by typing "+
     576                    "digraph.save(filename) to make this warning go away.")
    559577
    560578    def mutate(self):
    561579        """
     
    565583
    566584        - The networkx.DiGraph or networkx.MultiDiGraph corresponding to the
    567585          unpickled data.
     586
     587        EXAMPLES::
     588
     589            sage: from sage.graphs.base.graph_backends import NetworkXDiGraphDeprecated as NXDGD
     590            sage: X = NXDGD()
     591            doctest:...
     592            sage: X.adj = {1:{2:7}, 2:{1:[7,8], 3:[4,5,6,7]}}
     593            sage: X.multiedges = True
     594            sage: G = X.mutate()
     595            sage: G.edges()
     596            [(1, 2), (2, 1), (2, 3)]
     597            sage: G.edges(data=True)
     598            [(1, 2, {'weight': 7}), (2, 1, {8: {}, 7: {}}), (2, 3, {4: {}, 5: {}, 6: {}, 7: {}})]
     599
    568600        """
    569601        import networkx
    570602        new_adj = {}
     
    578610                        for weight in weights:
    579611                            new_adj[node1][node2][weight] = {}
    580612                    except TypeError:
    581                         new_adj[node1][node2]['weight'] = weight
     613                        new_adj[node1][node2]['weight'] = weights
    582614
    583615        if self.multiedges:
    584616            G = networkx.MultiDiGraph(new_adj)
  • sage/graphs/base/sparse_graph.pyx

    diff -r 59bc745f1cf1 -r c25879359da3 sage/graphs/base/sparse_graph.pyx
    a b  
    355355        bitset_free(self.active_vertices)
    356356
    357357    def __reduce__(self):
     358        """
     359        Return a tuple used for pickling this graph.
     360       
     361        TESTS::
     362
     363            sage: from sage.graphs.base.sparse_graph import SparseGraph
     364            sage: S = SparseGraph(nverts = 10, expected_degree = 3, extra_vertices = 10)
     365            sage: S.add_arc(0,1)
     366            sage: S.all_arcs(0,1)
     367            [0]
     368            sage: S.all_arcs(1,2)
     369            []
     370            sage: LS = loads(dumps(S))
     371            sage: LS.all_arcs(0,1)
     372            [0]
     373            sage: LS.all_arcs(1,2)
     374            []
     375
     376        """
    358377        from sage.graphs.all import DiGraph
    359378        D = DiGraph(implementation='c_graph', sparse=True)
    360379        D._backend._cg = self