You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This can be solved by converting node IDs to strings (G = nx.relabel_nodes(G, lambda x: str(x))) but it seems like a more general solution is to handle this in the embed_networkx call, since any non-JSON-serializable ID type will fail with this error.
(Traceback suggests that this is a failure of the node_link_data(graph) call on line 99 of embed.py)
[EDIT]: This still fails even if I verify that the data are JSON-serializable with
Could you give an example of a real matrix for which this is a problem?
Also, do you think that it's a good idea to try and bake more logic into the embed_networkx function? There could be lots of edge cases. A previous pull request added the ability to specify a JSONEncoder that can be made custom for any kinds of classes, so that might be able to fit more general needs without having to write more code in this library.
My main concern here is that the serialization error appears to be internal to nx2d3 rather than an issue with the data; using the python standard json library for serialization seems to work.
Definitely agree about not bloating this library though! Maybe a good middle ground is to throw a more readable error if serialization fails (for this or any other reason)?
When you try to render a graph derived from a numpy adjacency matrix, you get this error.
This can be solved by converting node IDs to strings (
G = nx.relabel_nodes(G, lambda x: str(x))
) but it seems like a more general solution is to handle this in theembed_networkx
call, since any non-JSON-serializable ID type will fail with this error.(Traceback suggests that this is a failure of the
node_link_data(graph)
call on line 99 ofembed.py
)[EDIT]: This still fails even if I verify that the data are JSON-serializable with
So this is a function of the nx2d3 library, not of the networkx JSON serializer, I believe.
The text was updated successfully, but these errors were encountered: