[Python-modules-commits] r22215 - in packages/python-networkx/trunk/debian (3 files)
morph at users.alioth.debian.org
morph at users.alioth.debian.org
Tue Jun 19 19:48:33 UTC 2012
Date: Tuesday, June 19, 2012 @ 19:48:28
Author: morph
Revision: 22215
* debian/patches/changeset_8960521b5ae4897bdbac4ff49525d8b37bff88d2.diff
- Handle empty graph (all zero matrix) and null graph (raise exception) in
to_scipy_sparse_matrix; thanks to Yaroslav Halchenko for the report;
Closes: #678036
Added:
packages/python-networkx/trunk/debian/patches/changeset_8960521b5ae4897bdbac4ff49525d8b37bff88d2.diff
Modified:
packages/python-networkx/trunk/debian/changelog
packages/python-networkx/trunk/debian/patches/series
Modified: packages/python-networkx/trunk/debian/changelog
===================================================================
--- packages/python-networkx/trunk/debian/changelog 2012-06-19 19:45:56 UTC (rev 22214)
+++ packages/python-networkx/trunk/debian/changelog 2012-06-19 19:48:28 UTC (rev 22215)
@@ -1,3 +1,12 @@
+python-networkx (1.7~rc1-2) UNRELEASED; urgency=low
+
+ * debian/patches/changeset_8960521b5ae4897bdbac4ff49525d8b37bff88d2.diff
+ - Handle empty graph (all zero matrix) and null graph (raise exception) in
+ to_scipy_sparse_matrix; thanks to Yaroslav Halchenko for the report;
+ Closes: #678036
+
+ -- Sandro Tosi <morph at debian.org> Tue, 19 Jun 2012 21:20:07 +0200
+
python-networkx (1.7~rc1-1) unstable; urgency=low
* New upstream release candidate
Added: packages/python-networkx/trunk/debian/patches/changeset_8960521b5ae4897bdbac4ff49525d8b37bff88d2.diff
===================================================================
--- packages/python-networkx/trunk/debian/patches/changeset_8960521b5ae4897bdbac4ff49525d8b37bff88d2.diff (rev 0)
+++ packages/python-networkx/trunk/debian/patches/changeset_8960521b5ae4897bdbac4ff49525d8b37bff88d2.diff 2012-06-19 19:48:28 UTC (rev 22215)
@@ -0,0 +1,43 @@
+Description: Handle empty graph (all zero matrix) and null graph (raise exception) in to_scipy_sparse_matrix.
+Origin: https://networkx.lanl.gov/trac/changeset/8960521b5ae4897bdbac4ff49525d8b37bff88d2/networkx
+Index: networkx/convert.py
+===================================================================
+--- python-networkx-1.7rc1.orig/networkx/convert.py (revision 2066)
++++ python-networkx-1.7rc1/networkx/convert.py (revision 2207)
+@@ -776,11 +776,16 @@
+ nodelist = G
+ nlen = len(nodelist)
++ if nlen == 0:
++ raise nx.NetworkXError("Graph has no nodes or edges")
+ index = dict(zip(set(nodelist),range(nlen)))
+ if len(nodelist) != len(index):
+ msg = "Ambiguous ordering: `nodelist` contained duplicates."
+ raise nx.NetworkXError(msg)
+- row,col,data=zip(*((index[u],index[v],d.get(weight,1))
+- for u,v,d in G.edges(nodelist, data=True)
+- if u in index and v in index))
++ if G.number_of_edges() == 0:
++ row,col,data=[],[],[]
++ else:
++ row,col,data=zip(*((index[u],index[v],d.get(weight,1))
++ for u,v,d in G.edges_iter(nodelist, data=True)
++ if u in index and v in index))
+ if G.is_directed():
+ M = sparse.coo_matrix((data,(row,col)),shape=(nlen,nlen), dtype=dtype)
+Index: networkx/tests/test_convert_scipy.py
+===================================================================
+--- python-networkx-1.7rc1.orig/networkx/tests/test_convert_scipy.py (revision 2066)
++++ python-networkx-1.7rc1/networkx/tests/test_convert_scipy.py (revision 2207)
+@@ -160,2 +160,12 @@
+ P4 = path_graph(4)
+ nx.to_scipy_sparse_matrix(P4, format='any_other')
++
++ @raises(nx.NetworkXError)
++ def test_null_fail(self):
++ nx.to_scipy_sparse_matrix(nx.Graph())
++
++ def test_empty(self):
++ G = nx.Graph()
++ G.add_node(1)
++ M = nx.to_scipy_sparse_matrix(G)
++ np_assert_equal(M.todense(), np.matrix([[0]]))
Modified: packages/python-networkx/trunk/debian/patches/series
===================================================================
--- packages/python-networkx/trunk/debian/patches/series 2012-06-19 19:45:56 UTC (rev 22214)
+++ packages/python-networkx/trunk/debian/patches/series 2012-06-19 19:48:28 UTC (rev 22215)
@@ -3,3 +3,4 @@
30_use_local_objects.inv
40_no_setuptools_in_requires.txt
changeset_fed4cb6e78dc7047c06522b0418ef5b0d8197290.diff
+changeset_8960521b5ae4897bdbac4ff49525d8b37bff88d2.diff
More information about the Python-modules-commits
mailing list