Ticket #13891: trac_13891-third_pass.patch

File trac_13891-third_pass.patch, 7.2 KB (added by ncohen, 6 years ago)
  • sage/combinat/posets/posets.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1359110977 -3600
    # Node ID e3d66ffe7e46871675c18f49f13c4120cc160319
    # Parent  18aba22e780a4504c975c79c0b4383cd687e8ac7
    Default parameters for Graph.plot() and Graph.show() -- third pass
    
    diff --git a/sage/combinat/posets/posets.py b/sage/combinat/posets/posets.py
    a b  
    13991399            sage: D.show(element_labels=elm_labs)
    14001400        """
    14011401        self.plot(label_elements=label_elements, element_labels=element_labels,
    1402             label_font_size=label_font_size,label_font_color=label_font_color,
    14031402            vertex_size=vertex_size, vertex_colors=vertex_colors, layout=layout).show(**kwds)
    14041403
    14051404    def level_sets(self):
  • sage/graphs/generic_graph.py

    diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
    a b  
    1380013800        Here is the list of all the available layout options::
    1380113801
    1380213802            sage: from sage.graphs.graph_plot import layout_options
    13803             sage: list(sorted(layout_options.iteritems()))
    13804             [('by_component', 'Whether to do the spring layout by connected component -- a boolean.'),
    13805              ('dim', 'The dimension of the layout -- 2 or 3.'),
    13806              ('heights', 'A dictionary mapping heights to the list of vertices at this height.'),
    13807              ('iterations', 'The number of times to execute the spring layout algorithm.'),
    13808              ('layout', 'A layout algorithm -- one of "acyclic", "circular", "ranked", "graphviz", "planar", "spring", or "tree".'),
    13809              ('prog', 'Which graphviz layout program to use -- one of "circo", "dot", "fdp", "neato", or "twopi".'),
    13810              ('save_pos', 'Whether or not to save the computed position for the graph.'),
    13811              ('spring', 'Use spring layout to finalize the current layout.'),
    13812              ('tree_orientation', 'The direction of tree branches -- "up" or "down".'),
    13813              ('tree_root', 'A vertex designation for drawing trees.')]
     13803            sage: for key, value in list(sorted(layout_options.iteritems())):
     13804            ...      print "option", key, ":", value
     13805            option by_component : Whether to do the spring layout by connected component -- a boolean.
     13806            option dim : The dimension of the layout -- 2 or 3.
     13807            option heights : A dictionary mapping heights to the list of vertices at this height.
     13808            option iterations : The number of times to execute the spring layout algorithm.
     13809            option layout : A layout algorithm -- one of : "acyclic", "circular" (plots the graph with vertices evenly distributed on a circle), "ranked", "graphviz", "planar", "spring" (traditional spring layout, using the graph's current positions as initial positions), or "tree" (the tree will be plotted in levels, depending on minimum distance for the root).
     13810            option prog : Which graphviz layout program to use -- one of "circo", "dot", "fdp", "neato", or "twopi".
     13811            option save_pos : Whether or not to save the computed position for the graph.
     13812            option spring : Use spring layout to finalize the current layout.
     13813            option tree_orientation : The direction of tree branches -- "up" or "down".
     13814            option tree_root : A vertex designation for drawing trees. a vertex of the tree to be used as the root for the ``layout="tree"`` option. If no root is specified, then one is chosen at random. Ignored unless ``layout='tree'``
    1381413815
    1381513816        Some of them only apply to certain layout algorithms. For
    1381613817        details, see :meth:`.layout_acyclic`, :meth:`.layout_planar`,
  • sage/graphs/graph_plot.py

    diff --git a/sage/graphs/graph_plot.py b/sage/graphs/graph_plot.py
    a b  
    7272for key, value in graphplot_options.iteritems():
    7373    __doc__ += "    ``"+str(key)+"`` | "+str(value)+"\n"
    7474
     75
    7576__doc__ += """
    76 
    7777**Default options**
    7878
    7979This module defines two dictionaries containing default options for the
     
    212212        Wrong input::
    213213
    214214            sage: graphs.PetersenGraph().plot(kujhfuhf="23")
    215             doctest:...: DeprecationWarning: kujhfuhf is not a registered argument forGraphPlot ! Please tell us that if it should be by writing to sage-devel !
     215            doctest:...: DeprecationWarning: You provided kujhfuhf as an
     216            argument to a function which has always silently ignored its
     217            inputs. This method may soon be updated so that the method raises an
     218            exception instead of this warning, which will break your code : to
     219            be on the safe side, update it !
    216220            ...
    217221        """
    218222        # Setting the default values if needed
     
    223227        for opt in options:
    224228            if not opt in graphplot_options:
    225229                from sage.misc.superseded import deprecation
    226                 deprecation(13891, (str(opt)+" is not a registered argument for"+
    227                                       "GraphPlot ! Please tell us that if it "+
    228                                       "should be by writing to sage-devel !"))
     230                deprecation(13891, ("You provided "+str(opt)+" as an argument to a "
     231                                    "function which has always silently ignored "
     232                                    "its inputs. This method may soon be updated "
     233                                    "so that the method raises an exception "
     234                                    "instead of this warning, which will break "
     235                                    "your code : to be on the safe side, update it !"))
    229236
    230237        self._plot_components = {}
    231238        self._nodelist = graph.vertices()
     
    701708
    702709        self.plot().show(**kwds)
    703710
    704     def plot(self):
     711    def plot(self, **kwds):
    705712        """
    706713        Returns a graphics object representing the (di)graph.
    707714
     
    843850            sage: g.add_edges([(0,0,'a'),(0,0,'b'),(0,1,'c'),(0,1,'d'),
    844851            ...     (0,1,'e'),(0,1,'f'),(0,1,'f'),(2,1,'g'),(2,2,'h')])
    845852            sage: g.graphplot(edge_labels=True, color_by_label=True, edge_style='dashed').plot()
     853
     854        Wrong input (any input) :trac:`13891`::
     855
     856            sage: graphs.PetersenGraph().graphplot().plot(aertataert=346345345)
     857            doctest:...: DeprecationWarning: This method takes no argument ! You may want to give it as an argument to graphplot instead.
     858            See http://trac.sagemath.org/13891 for details.
     859            <BLANKLINE>
    846860        """
     861        # This method takes NO input
     862        # This has been added in early 2013. Remove it before my death, please.
     863        if kwds:
     864            from sage.misc.superseded import deprecation
     865            deprecation(13891, "This method takes no argument ! You may want "
     866                               "to give it as an argument to graphplot instead.")
     867
    847868        G = Graphics()
    848869        for comp in self._plot_components.values():
    849870            if not isinstance(comp, list):
     
    851872            else:
    852873                for item in comp:
    853874                    G += item
     875
    854876        G.set_axes_range(*(self._graph._layout_bounding_box(self._pos)))
    855877        if self._options['graph_border']:
    856878            xmin = G.xmin()