#13132: Small string formatting bug in Graph.delete_vertex
----------------------------+-----------------------------------------------
Reporter: tjolivet | Owner: jason, ncohen, rlm
Type: defect | Status: new
Priority: major | Milestone: sage-5.1
Component: graph theory | Keywords:
Work issues: | Report Upstream: N/A
Reviewers: | Authors:
Merged in: | Dependencies:
Stopgaps: |
----------------------------+-----------------------------------------------
If we remove a vertex which is a tuple from a graph which does not contain
this vertex, Sage fails because it raises a `TypeError` instead of the
usual `RuntimeError: Vertex (1) not in the graph.`
{{{
sage: G = Graph()
sage: G.delete_vertex((1,'a'))
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
/home/jaje/e_one_star/<ipython console> in <module>()
/home/jaje/sage-5.0.1/local/lib/python2.7/site-
packages/sage/graphs/generic_graph.pyc in delete_vertex(self, vertex,
in_order)
7247 vertex = self.vertices()[vertex]
7248 if vertex not in self:
-> 7249 raise RuntimeError("Vertex (%s) not in the
graph."%vertex)
7250
7251 attributes_to_update = ('_pos', '_assoc', '_embedding')
TypeError: not all arguments converted during string formatting
}}}
This is because the source code reads
{{{
raise RuntimeError("Vertex (%s) not in the graph."%vertex)
}}}
so it fails if `vertex` is a tuple (too many values to unpack for the
`%s`), as illustrated here:
{{{
sage: "BLA%sBLA"%(1,'a')
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
/home/jaje/e_one_star/<ipython console> in <module>()
TypeError: not all arguments converted during string formatting
sage: "BLA%sBLA"%str((1,'a'))
"BLA(1, 'a')BLA"
}}}
I guess this bug can just be corrected by replacing all the occurrences of
`%vertex` by `%str(vertex)`. It also occurs in `DiGraph.delete_vertex`.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13132>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.