Skip to content

Commit

Permalink
Fix broken tests using deprecated matplotlib function from 3.6.0 (closes
Browse files Browse the repository at this point in the history
 qiskit-community#909) (qiskit-community#910)

* Fix broken tests using deprecated matplotlib function from 3.6.0
  • Loading branch information
conradhaupt authored Sep 16, 2022
1 parent 0eaef05 commit 1f6d985
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
15 changes: 12 additions & 3 deletions qiskit_experiments/curve_analysis/visualization/mpl_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,21 @@ def format_canvas(self):

# Auto-scale all axes to the first sub axis
if ax_type == "x":
all_axes[0].get_shared_x_axes().join(*all_axes)
# get_shared_y_axes() is immutable from matplotlib>=3.6.0. Must use Axis.sharey()
# instead, but this can only be called once per axis. Here we call sharey on all axes in
# a chain, which should have the same effect.
if len(all_axes) > 1:
for ax1, ax2 in zip(all_axes[1:], all_axes[0:-1]):
ax1.sharex(ax2)
all_axes[0].set_xlim(lim)
else:
all_axes[0].get_shared_y_axes().join(*all_axes)
# get_shared_y_axes() is immutable from matplotlib>=3.6.0. Must use Axis.sharey()
# instead, but this can only be called once per axis. Here we call sharey on all axes in
# a chain, which should have the same effect.
if len(all_axes) > 1:
for ax1, ax2 in zip(all_axes[1:], all_axes[0:-1]):
ax1.sharey(ax2)
all_axes[0].set_ylim(lim)

# Add title
if self.options.figure_title is not None:
self._axis.set_title(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Fix a bug where :class:`CurveAnalysis` tests would fail with matplotlib 3.6.0 owing to a deprecated
function call used in :class:`MplCurveDrawer`. The new :class:`MplCurveDrawer` no-longer uses the
deprecated function.
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ scipy>=1.4
qiskit-terra>=0.21.1
qiskit-ibmq-provider>=0.16.0
qiskit-ibm-experiment>=0.2.5
# FIXME: Remove maximum version once bugs discussed in #909, #910, #911 have been fixed.
matplotlib>=3.4,<3.6
matplotlib>=3.4
uncertainties
lmfit

0 comments on commit 1f6d985

Please sign in to comment.