Conversation
networkx/linalg/laplacianmatrix.py
Outdated
| matrix for each component. | ||
|
|
||
| >>> G = nx.graph_atlas(26) #This graph from the Graph Atlas has 2 connected components. | ||
| >>> print(nx.laplacian_matrix(G).todense()) |
There was a problem hiding this comment.
Using toarray would be preferable to todense here - we can also then get rid of the print and just rely on the array repr.
There was a problem hiding this comment.
Using
toarraywould be preferable totodensehere - we can also then get rid of the
Without the print there are some docs tests that failed due to differences in some OS. On Windows at the end of the array is added dtype=int32) but not on Ubuntu. Should I add the print back?
There was a problem hiding this comment.
Interesting - I wasn't expecting that but I suppose makes sense given windows integer types.
I suppose the two options are to add the print back or add an explicit cast, e.g. toarray().astype(np.int64). Neither is ideal but both should be fine, so whatever you think is best!
There was a problem hiding this comment.
The platform-specific printing is likely related to something in numpy itself, see numpy/numpy#22586.
In the meantime, the printing workaround seems fine to me!
rossbar
left a comment
There was a problem hiding this comment.
Thanks @paulitapb , just one code style nit that I took the liberty of pushing up (I think it should've been caught by blacken-docs in CI?). LGTM!
* add example laplacian matrix * Add example laplacian_matrix * fix style * add explicit example * add print back * Fix code style in example. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* add example laplacian matrix * Add example laplacian_matrix * fix style * add explicit example * add print back * Fix code style in example. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
No description provided.