dwavesystems / dwave-system

An API for easily incorporating the D-Wave system as a sampler, either directly or through Leap's cloud-based hybrid samplers
https://docs.ocean.dwavesys.com/
Apache License 2.0
86 stars 61 forks source link

Add draw_chimera_bqm to docs #181

Open arcondello opened 5 years ago

arcondello commented 5 years ago

Add function added by #156 to the docs

JoelPasvolsky commented 4 years ago

@arcondello, noticed this function and example as I went through the file, tried it but it fails, and that brought me to this issue.

draw_chimera_bqm(BinaryQuadraticModel.from_qubo(Q), width=1, height=1)  
/home/jpasvolsky/Work/MyVirtualEnvironments/dimod/lib/python3.5/site-packages/networkx/drawing/nx_pylab.py:565: MatplotlibDeprecationWarning: isinstance(..., numbers.Number)
  if cb.is_numlike(alpha):
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-4cb31be40579> in <module>
----> 1 draw_chimera_bqm(BinaryQuadraticModel.from_qubo(Q), width=1, height=1)

~/Work/MyVirtualEnvironments/dimod/lib/python3.5/site-packages/dwave/embedding/drawing.py in draw_chimera_bqm(bqm, width, height)
    101     # Draw your graph over the complete graph to show the connectivity.
    102     draw_chimera(G, node_size=node_size, linear_biases=bqm.linear, quadratic_biases=bqm.quadratic,
--> 103                      width=3)
    104     return

~/Work/MyVirtualEnvironments/dimod/lib/python3.5/site-packages/dwave_networkx/drawing/chimera_layout.py in draw_chimera(G, **kwargs)
    241 
    242     """
--> 243     draw_qubit_graph(G, chimera_layout(G), **kwargs)
    244 
    245 

~/Work/MyVirtualEnvironments/dimod/lib/python3.5/site-packages/dwave_networkx/drawing/qubit_layout.py in draw_qubit_graph(G, layout, linear_biases, quadratic_biases, nodelist, edgelist, cmap, edge_cmap, vmin, vmax, edge_vmin, edge_vmax, midpoint, **kwargs)
    167             if midpoint is None:
    168                 midpoint = (global_vmax + global_vmin) / 2.0
--> 169             norm_map = mpl.colors.DivergingNorm(midpoint, vmin=global_vmin, vmax=global_vmax)
    170 
    171             node_color = [cmap(norm_map(node)) for node in node_color]

AttributeError: module 'matplotlib.colors' has no attribute 'DivergingNorm'