Skip to content

Commit

Permalink
Replace deprecated mpl function in unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
nkanazawa1989 committed Sep 19, 2023
1 parent f2e5d8b commit aaa7d36
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions test/visualization/test_plotter_mpldrawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def test_series_names_different_types(self, series_names: Dict[type, List[Any]])
# have `tostring_rgb()` which is needed to compute the difference between two figures in this
# method. We need to set the axes as MplDrawer will use
# `qiskit_experiments.framework.matplotlib.get_non_gui_ax` by default; which uses an SVG backend.
plt.close("all")
plt.switch_backend("Agg")
axes = {}
for key in series_names.keys():
Expand Down Expand Up @@ -167,10 +168,7 @@ def test_series_names_different_types(self, series_names: Dict[type, List[Any]])
for plotter_type, plotter in plotters.items():
figure = plotter.figure().figure
figure.canvas.draw()
figure_data[plotter_type] = np.frombuffer(
figure.canvas.tostring_rgb(),
dtype=np.uint8,
).reshape(figure.canvas.get_width_height() + (3,))
figure_data[plotter_type] = np.asarray(figure.canvas.buffer_rgba(), dtype=np.uint8)

# Compare root-mean-squared error between two images.
for (fig1_type, fig1), (fig2_type, fig2) in combinations(figure_data.items(), 2):
Expand Down

0 comments on commit aaa7d36

Please sign in to comment.