Open JoelPasvolsky opened 3 years ago
Worth noting that networkx.Graph
is not itself JSON-serializable, Bokeh has implemented a custom encoder BokehJSONEncoder
.
So I think the request is really "Graph output should be serializable by Bokeh's custom encoder"
IMO this is not an easy fix. Simplest would be del G.vartype
.
Error persists (TypeError: Object of type 'Vartype' is not JSON serializable
) even after deleting it.
G = dimod.to_networkx_graph(bqm)
print(G.vartype)
del G.vartype
print(G.vartype)
Vartype.SPIN
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-29-4497731d6b2b> in <module>()
2 print(G.vartype)
3 del G.vartype
----> 4 print(G.vartype)
AttributeError: 'Graph' object has no attribute 'vartype'
try plotting again:
show(plot)
TypeError Traceback (most recent call last)
...
TypeError: Object of type 'Vartype' is not JSON serializable
Ah, got it, comes from https://github.com/dwavesystems/dimod/blob/126a9056c4226d6955395620efb94ebee07581a5/dimod/converters.py#L49
Ok. I think your workaround it best for now.
Description Try to convert a BQM (either default or AdjDictBQM) to a networkx graph, then use bokeh to plot, and bokeh gives a
TypeError: Object of type 'Vartype' is not JSON serializable
error.Steps To Reproduce
Expected Behavior Graph output should be serializable
Environment
Additional Context Workaround: convert without the vartype.
Below is the full error message: