summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Mazières <antoine.mazieres@gmail.com>2015-10-27 21:47:17 +0100
committerAntoine Mazières <antoine.mazieres@gmail.com>2015-10-27 21:47:17 +0100
commit85d3e4265fefc18bf77f8e2a58ced81325d17890 (patch)
treea7e14046cf26ced3cfbe46f859ce23a0afa2e168
parent87a620eae4f0afaa9ab9fd86e87e64b40dac3685 (diff)
downloadnetworkx-85d3e4265fefc18bf77f8e2a58ced81325d17890.tar.gz
Fix, now raise NetworkXError instead of TypeError
Instead of : ``` 'dict' objects are unhashableTraceback (most recent call last): File "<builtin>/app_main.py", line 75, in run_toplevel File "mk_graph_file.py", line 34, in <module> if d['weight'] > 3]) File "/usr/local/lib/pypy2.7/dist-packages/networkx/classes/graph.py", line 1488, in subgraph for n in bunch: File "/usr/local/lib/pypy2.7/dist-packages/networkx/classes/graph.py", line 1815, in bunch_iter "Node %s in the sequence nbunch is not a valid node."%n) TypeError: not all arguments converted during string formatting ``` You get: ``` 'dict' objects are unhashableTraceback (most recent call last): File "<builtin>/app_main.py", line 75, in run_toplevel File "mk_graph_file.py", line 34, in <module> if d['weight'] > 3]) File "/usr/local/lib/pypy2.7/dist-packages/networkx/classes/graph.py", line 1488, in subgraph for n in bunch: File "/usr/local/lib/pypy2.7/dist-packages/networkx/classes/graph.py", line 1815, in bunch_iter "Node {} in the sequence nbunch is not a valid node.".format(n)) NetworkXError: Node ('java', 'performance', {'weight': 5}) in the sequence nbunch is not a valid node. ```
-rw-r--r--networkx/classes/graph.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/networkx/classes/graph.py b/networkx/classes/graph.py
index 7ea3b91c..b12b960a 100644
--- a/networkx/classes/graph.py
+++ b/networkx/classes/graph.py
@@ -1768,7 +1768,7 @@ class Graph(object):
# capture error for unhashable node.
elif 'hashable' in message:
raise NetworkXError(
- "Node %s in the sequence nbunch is not a valid node."%n)
+ "Node {} in the sequence nbunch is not a valid node.".format(n))
else:
raise
bunch = bunch_iter(nbunch, self.adj)