Repository navigation
Add a nodelist feature to from_numpy_array - #7412
Conversation
There was a problem hiding this comment.
This looks really good! I like it. :)
I especially like the organization of the tests. And the choice of how/when to switch from idxs to nodes.
As far as the kwarg name, the term label could be confusing since sometimes label is an attribute of the node rather than the node itself. The choice nodelist matches the kwarg in the function to_numpy_array, so might be good. But of course it doesn't have to be of a list. So ... ???
It's great that you have included the simple example from #7407 here as a test.
node_labels feature to from_numpy_arraynodelist feature to from_numpy_array
I totally agree, thanks for the suggestion - renamed to nodelist in 86fee52. +1 for consistencey with The docstring has been updated as well from |
45f59c7 to
958ec1e
Compare
Co-authored-by: Dan Schult <[email protected]>
Co-authored-by: Dan Schult <[email protected]>
dschult
left a comment
There was a problem hiding this comment.
This looks good to me...
One suggestion. But I approve either way.
Co-authored-by: Dan Schult <[email protected]>
* Add tests for node_labels in from_numpy_array. * Implement node_labels feature. * Add round-tripping test for different simple graphs. * Fix for networkxgh-7407. * Rename node_labels -> nodelist. Co-authored-by: Dan Schult <[email protected]> * Update docstring. Co-authored-by: Dan Schult <[email protected]> * Add match to pytest.raises. * Update networkx/tests/test_convert_numpy.py Co-authored-by: Dan Schult <[email protected]> --------- Co-authored-by: Dan Schult <[email protected]>
Adds a kwarg to allow users to specify a sequence of nodes which map to the dimensions of the adjacency matrix. The mapping implicitly relies on the ordering of the nodes in the adjacency matrix, i.e.
node_labels[0] -> row 0,node_labels[1] -> row 1, etc.I'm not sure about the name of the kwarg. One motivating factor for this proposal is it fixes #7407 in an efficient way. I've added that change in a1a17ac7, but I'm happy to break that into a separate PR in order to focus on the new feature proposal!