From a90e4ab9225b4e6bee2b8e1c537385742c21cafe Mon Sep 17 00:00:00 2001 From: chrishavlin Date: Tue, 23 Apr 2024 17:15:21 -0500 Subject: [PATCH 1/2] add QtAgg backend specs, rm Qt4Agg --- yt/visualization/base_plot_types.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yt/visualization/base_plot_types.py b/yt/visualization/base_plot_types.py index 716ee7c9bd5..c00a793288f 100644 --- a/yt/visualization/base_plot_types.py +++ b/yt/visualization/base_plot_types.py @@ -49,8 +49,8 @@ class FormatKwargs(TypedDict): "GTKAgg": ["backend_gtkagg", "FigureCanvasGTKAgg", None], "GTKCairo": ["backend_gtkcairo", "FigureCanvasGTKCairo", None], "MacOSX": ["backend_macosx", "FigureCanvasMac", "FigureManagerMac"], - "Qt4Agg": ["backend_qt4agg", "FigureCanvasQTAgg", None], "Qt5Agg": ["backend_qt5agg", "FigureCanvasQTAgg", None], + "QtAgg": ["backend_qtagg", "FigureCanvasQTAgg", None], "TkAgg": ["backend_tkagg", "FigureCanvasTkAgg", None], "WX": ["backend_wx", "FigureCanvasWx", None], "WXAgg": ["backend_wxagg", "FigureCanvasWxAgg", None], @@ -157,8 +157,9 @@ def _get_canvas_classes(self): try: module, fig_canvas, fig_manager = BACKEND_SPECS[key] - except KeyError: - return + except KeyError as err: + msg = f"{key} is not in list of valid backends: {list(BACKEND_SPECS)}." + raise KeyError(msg) from err mod = __import__( "matplotlib.backends", From eb4164c97ce6b10058182c12a4d6311ddc42052e Mon Sep 17 00:00:00 2001 From: chavlin Date: Wed, 24 Apr 2024 15:10:08 -0500 Subject: [PATCH 2/2] allow invalid backend to error --- yt/visualization/base_plot_types.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/yt/visualization/base_plot_types.py b/yt/visualization/base_plot_types.py index c00a793288f..263a563f695 100644 --- a/yt/visualization/base_plot_types.py +++ b/yt/visualization/base_plot_types.py @@ -155,11 +155,7 @@ def _get_canvas_classes(self): else: key = "agg" - try: - module, fig_canvas, fig_manager = BACKEND_SPECS[key] - except KeyError as err: - msg = f"{key} is not in list of valid backends: {list(BACKEND_SPECS)}." - raise KeyError(msg) from err + module, fig_canvas, fig_manager = BACKEND_SPECS[key] mod = __import__( "matplotlib.backends",