Skip to content

Commit

Permalink
Merge branch 'main' into IS-1244
Browse files Browse the repository at this point in the history
  • Loading branch information
ItamarGoldman committed Sep 28, 2023
2 parents 89892c9 + 8802a29 commit a55dcc2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cron-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, "3.11"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
steps:
- name: Print Concurrency Group
Expand Down
15 changes: 8 additions & 7 deletions test/visualization/test_plotter_mpldrawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
class TestPlotterAndMplDrawer(QiskitExperimentsTestCase):
"""Test generic plotter with Matplotlib drawer."""

def tearDown(self):
"""Clean up test case state"""
plt.close("all")
super().tearDown()

def test_end_to_end_short(self):
"""Test whether plotter with MplDrawer returns a figure."""
plotter = MockPlotter(MplDrawer())
Expand Down Expand Up @@ -118,7 +123,7 @@ 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.switch_backend("Agg")
Expand Down Expand Up @@ -161,16 +166,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 a55dcc2

Please sign in to comment.