diff options
author | mtrenfield <m.trenfield@gmail.com> | 2018-07-24 22:16:19 -0500 |
---|---|---|
committer | Dan Schult <dschult@colgate.edu> | 2018-07-24 23:16:19 -0400 |
commit | ab3a6cdece25e359f28526fdc5f9f8ae443503f3 (patch) | |
tree | f001dbe11ca8d208b07827bfdeee8c5e77cb3df8 /networkx/convert_matrix.py | |
parent | 5fbd78e9815843a97fc01afc0a7de3b51440ef66 (diff) | |
download | networkx-ab3a6cdece25e359f28526fdc5f9f8ae443503f3.tar.gz |
Numpy matrix edge fix issue 3086 (#3087)
* modified from_numpy_matrix so that it returns a graph that has (int, int) as edges instead of numpy data types
* Added test of this trouble in test_convert_numpy.py
Fixes #3086
Diffstat (limited to 'networkx/convert_matrix.py')
-rw-r--r-- | networkx/convert_matrix.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/networkx/convert_matrix.py b/networkx/convert_matrix.py index 2d1c82c2..efc23785 100644 --- a/networkx/convert_matrix.py +++ b/networkx/convert_matrix.py @@ -560,7 +560,8 @@ def from_numpy_matrix(A, parallel_edges=False, create_using=None): G.add_nodes_from(range(n)) # Get a list of all the entries in the matrix with nonzero entries. These # coordinates will become the edges in the graph. - edges = zip(*(np.asarray(A).nonzero())) + edges = map(lambda e: (int(e[0]), int(e[1])), + zip(*(np.asarray(A).nonzero()))) # handle numpy constructed data type if python_type is 'void': # Sort the fields by their offset, then by dtype, then by name. |