Skip to content

Commit

Permalink
Merge branch 'stable/0.5' into mergify/bp/stable/0.5/pr-1293
Browse files Browse the repository at this point in the history
  • Loading branch information
coruscating authored Oct 31, 2023
2 parents 3ce4ebf + 420fc58 commit d127249
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ reno>=4.0.0
nbsphinx
arxiv
ddt>=1.6.0
qiskit-aer>=0.11.0
qiskit-aer>=0.11.0,<=0.12.2 # Temporary version pin because of https://github.com/Qiskit-Extensions/qiskit-experiments/issues/1292
pandas>=1.1.5
cvxpy>=1.1.15
pylatexenc
Expand Down
11 changes: 4 additions & 7 deletions test/visualization/test_plotter_mpldrawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ def test_series_names_different_types(self, series_names: Dict[type, List[Any]])
"""

# Create Matplotlib axes that use a PNG backend. The default backend, FigureCanvasSVG, does not
# have `tostring_rgb()` which is needed to compute the difference between two figures in this
# have `buffer_rgba()` 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 @@ -151,16 +152,12 @@ def test_series_names_different_types(self, series_names: Dict[type, List[Any]])
for plot_type in legend_plot_types:
plotter.enable_legend_for(series_name, plot_type)

# Generate figure and save to buffers for comparison. This requires a pixel backend, like AGG, so
# that `tostring_rgb()` is available.
# Generate figure and save to buffers for comparison.
figure_data = {}
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 d127249

Please sign in to comment.