and here we go -- was my mistake of mixing up two patch sets. If upload of 1.7 official release to wheezy is impossible, please include the commit 9ebe087b8bbcdeee3051e07cacd05fa07436c16e (attached, thanks Satra once again for pointing it out) which resolves the FTBFS of nipype.
Best regards, > unfortunately wasn't a good once since that particular commit was already > present in Debian package: > http://patch-tracker.debian.org/patch/series/view/python-networkx/1.7~rc1-2/changeset_8960521b5ae4897bdbac4ff49525d8b37bff88d2.diff > but it seems that nipype doesn't experience the issue with 1.7 release (now at > run 50 while before it was either crashing or stalling well before run 20) -- Yaroslav O. Halchenko Postdoctoral Fellow, Department of Psychological and Brain Sciences Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755 Phone: +1 (603) 646-9834 Fax: +1 (603) 646-1419 WWW: http://www.linkedin.com/in/yarik
From 9ebe087b8bbcdeee3051e07cacd05fa07436c16e Mon Sep 17 00:00:00 2001 From: Aric Hagberg <aric.hagb...@gmail.com> Date: Fri, 29 Jun 2012 21:30:38 -0600 Subject: [PATCH] Preserver order in G.nodes() or given in nodelist when converting to scipy sparse matrix. Update docs to reflect use of COO matrix. Addresses #737 --- networkx/convert.py | 8 +++++--- networkx/tests/test_convert_scipy.py | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/networkx/convert.py b/networkx/convert.py index 833c754..6333b9f 100644 --- a/networkx/convert.py +++ b/networkx/convert.py @@ -745,7 +745,7 @@ def to_scipy_sparse_matrix(G, nodelist=None, dtype=None, When `nodelist` does not contain every node in `G`, the matrix is built from the subgraph of `G` that is induced by the nodes in `nodelist`. - Uses lil_matrix format. To convert to other formats specify the + Uses coo_matrix format. To convert to other formats specify the format= keyword. Examples @@ -777,10 +777,12 @@ def to_scipy_sparse_matrix(G, nodelist=None, dtype=None, 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): + + if len(nodelist) != len(set(nodelist)): msg = "Ambiguous ordering: `nodelist` contained duplicates." raise nx.NetworkXError(msg) + + index = dict(zip(nodelist,range(nlen))) if G.number_of_edges() == 0: row,col,data=[],[],[] else: diff --git a/networkx/tests/test_convert_scipy.py b/networkx/tests/test_convert_scipy.py index 27ab786..f90dee7 100644 --- a/networkx/tests/test_convert_scipy.py +++ b/networkx/tests/test_convert_scipy.py @@ -169,3 +169,11 @@ class TestConvertNumpy(object): G.add_node(1) M = nx.to_scipy_sparse_matrix(G) np_assert_equal(M.todense(), np.matrix([[0]])) + + def test_ordering(self): + G = nx.DiGraph() + G.add_edge(1,2) + G.add_edge(2,3) + G.add_edge(3,1) + M = nx.to_scipy_sparse_matrix(G,nodelist=[3,2,1]) + np_assert_equal(M.todense(), np.matrix([[0,0,1],[1,0,0],[0,1,0]])) -- 1.7.10.4
signature.asc
Description: Digital signature