def test_two_qubit_nearest_neighbor(ax): value_map = { (grid_qubit.GridQubit(3, 2), grid_qubit.GridQubit(4, 2)): 0.004619111460557768, (grid_qubit.GridQubit(4, 1), grid_qubit.GridQubit(3, 2)): 0.0076079162393482835, } with pytest.raises(ValueError, match="not nearest neighbors"): heatmap.TwoQubitInteractionHeatmap(value_map, coupler_width=0).plot(ax)
def test_invalid_args(): value_map = { (grid_qubit.GridQubit(3, 2), grid_qubit.GridQubit(4, 2)): 0.004619111460557768, (grid_qubit.GridQubit(4, 1), grid_qubit.GridQubit(4, 2)): 0.0076079162393482835, } with pytest.raises(ValueError, match="invalid argument.*colormap"): heatmap.TwoQubitInteractionHeatmap(value_map, colormap='Greys')
def test_two_qubit_heatmap(ax): value_map = { (grid_qubit.GridQubit(3, 2), grid_qubit.GridQubit(4, 2)): 0.004619111460557768, (grid_qubit.GridQubit(4, 1), grid_qubit.GridQubit(4, 2)): 0.0076079162393482835, } title = "Two Qubit Interaction Heatmap" heatmap.TwoQubitInteractionHeatmap(value_map, title=title).plot(ax) assert ax.get_title() == title
def test_plot_updates_local_config(): value_map_2d = { (grid_qubit.GridQubit(3, 2), grid_qubit.GridQubit(4, 2)): 0.004619111460557768, (grid_qubit.GridQubit(4, 1), grid_qubit.GridQubit(4, 2)): 0.0076079162393482835, } value_map_1d = { (grid_qubit.GridQubit(3, 2), ): 0.004619111460557768, (grid_qubit.GridQubit(4, 2), ): 0.0076079162393482835, } original_title = "Two Qubit Interaction Heatmap" new_title = "Temporary title for the plot" for random_heatmap in [ heatmap.TwoQubitInteractionHeatmap(value_map_2d, title=original_title), heatmap.Heatmap(value_map_1d, title=original_title), ]: _, ax = plt.subplots() random_heatmap.plot(ax, title=new_title) assert ax.get_title() == new_title _, ax = plt.subplots() random_heatmap.plot(ax) assert ax.get_title() == original_title