From 81820ebc68ed1e59d1a3ff91f1f5e2e598a05a38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Sep 2023 19:13:55 +0000 Subject: [PATCH 1/2] Update matplotlib requirement from ~=3.7.0 to ~=3.8.0 Updates the requirements on [matplotlib](https://github.com/matplotlib/matplotlib) to permit the latest version. - [Release notes](https://github.com/matplotlib/matplotlib/releases) - [Commits](https://github.com/matplotlib/matplotlib/compare/v3.7.0...v3.8.0) --- updated-dependencies: - dependency-name: matplotlib dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5a59874bf39..53689992774 100644 --- a/requirements.txt +++ b/requirements.txt @@ -68,7 +68,7 @@ kiwisolver~=1.4.4 lazy_loader==0.3 lxml~=4.9.1 MarkupSafe~=2.1.1 -matplotlib~=3.7.0 +matplotlib~=3.8.0 matplotlib-inline==0.1.6 mistune~=3.0.1 msal~=1.24.0 From 29467290c8d321bdf48e8b1fef3ab9e90e0fe95f Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Sat, 16 Sep 2023 08:24:48 +0200 Subject: [PATCH 2/2] fix typechecking with matplotlib 3.8 --- pyproject.toml | 1 - qcodes/dataset/dond/do_nd_utils.py | 2 +- qcodes/dataset/plotting.py | 8 +++++++- qcodes/plotting/matplotlib_helpers.py | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f9c1d10ad9e..e13eae5705d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -190,7 +190,6 @@ module = [ "gclib", "ipywidgets", "h5netcdf", - "matplotlib.*", "mcl_RF_Switch_Controller64", "mcl_RF_Switch_Controller_NET45", "opencensus.ext.azure.*", diff --git a/qcodes/dataset/dond/do_nd_utils.py b/qcodes/dataset/dond/do_nd_utils.py index 15084666e26..55a1f405d52 100644 --- a/qcodes/dataset/dond/do_nd_utils.py +++ b/qcodes/dataset/dond/do_nd_utils.py @@ -35,7 +35,7 @@ ] MultiAxesTupleListWithDataSet = tuple[ tuple[DataSetProtocol, ...], - tuple[tuple["matplotlib.axes.Axes", ...], ...], + tuple[tuple[Optional["matplotlib.axes.Axes"], ...], ...], tuple[tuple[Optional["matplotlib.colorbar.Colorbar"], ...], ...], ] diff --git a/qcodes/dataset/plotting.py b/qcodes/dataset/plotting.py index 9090e63eb3c..763e596b5a5 100644 --- a/qcodes/dataset/plotting.py +++ b/qcodes/dataset/plotting.py @@ -14,6 +14,7 @@ from typing import TYPE_CHECKING, Any, Literal, Optional, cast import numpy as np +from matplotlib.figure import Figure if TYPE_CHECKING: import matplotlib @@ -350,6 +351,7 @@ def plot_and_save_image( os.makedirs(png_dir, exist_ok=True) os.makedirs(pdf_dif, exist_ok=True) for i, ax in enumerate(axes): + assert isinstance(ax.figure, Figure) if save_pdf: full_path = os.path.join(pdf_dif, f"{dataid}_{i}.pdf") ax.figure.savefig(full_path, dpi=500, bbox_inches="tight") @@ -591,8 +593,11 @@ def plot_2d_scatterplot( name = getattr(cmap, "name", _DEFAULT_COLORMAP) cmap = matplotlib.cm.get_cmap(name, len(z_strings)) - mappable = ax.scatter(x=x, y=y, c=z, rasterized=rasterized, cmap=cmap, **kwargs) + # according to the docs the c argument should support an ndarray + # but that fails type checking + mappable = ax.scatter(x=x, y=y, c=z, rasterized=rasterized, cmap=cmap, **kwargs) # type: ignore[arg-type] + assert ax.figure is not None if colorbar is not None: colorbar = ax.figure.colorbar(mappable, ax=ax, cax=colorbar.ax) else: @@ -705,6 +710,7 @@ def plot_on_a_plain_grid( ax.set_yticks(np.arange(len(np.unique(y_strings)))) ax.set_yticklabels(y_strings) + assert ax.figure is not None if colorbar is not None: colorbar = ax.figure.colorbar(colormesh, ax=ax, cax=colorbar.ax) else: diff --git a/qcodes/plotting/matplotlib_helpers.py b/qcodes/plotting/matplotlib_helpers.py index fbc69ee3935..c416c1ec2e7 100644 --- a/qcodes/plotting/matplotlib_helpers.py +++ b/qcodes/plotting/matplotlib_helpers.py @@ -46,7 +46,7 @@ def _set_colorbar_extend( "min": slice(1, None), "max": slice(0, -1), } - colorbar._inside = _slice_dict[extend] # pyright: ignore[reportGeneralTypeIssues] + colorbar._inside = _slice_dict[extend] # type: ignore[attr-defined] def apply_color_scale_limits(