From c82a2330e56c07ed9065506f16de7607ca2c2b3d Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@stfc.ac.uk> Date: Thu, 16 Aug 2018 15:26:11 +0100 Subject: [PATCH] Replace map with for loop map in Python 2 performed the loop iteration immediately and returned a list whereas Python 3 returns an iterator for lazy evaluation. If you don't care about the result the iteration never happens! --- qt/applications/workbench/workbench/app/mainwindow.py | 3 ++- qt/applications/workbench/workbench/plotting/figuremanager.py | 3 ++- qt/applications/workbench/workbench/plotting/functions.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/qt/applications/workbench/workbench/app/mainwindow.py b/qt/applications/workbench/workbench/app/mainwindow.py index 5bc70668d16..e1a5b0a9017 100644 --- a/qt/applications/workbench/workbench/app/mainwindow.py +++ b/qt/applications/workbench/workbench/app/mainwindow.py @@ -307,7 +307,8 @@ class MainWindow(QMainWindow): # flatten list widgets = [item for column in widgets_layout for row in column for item in row] # show everything - map(lambda w: w.toggle_view(True), widgets) + for w in widgets: + w.toggle_view(True) # split everything on the horizontal for i in range(len(widgets) - 1): first, second = widgets[i], widgets[i+1] diff --git a/qt/applications/workbench/workbench/plotting/figuremanager.py b/qt/applications/workbench/workbench/plotting/figuremanager.py index d85fd35bd92..434a19e30b9 100644 --- a/qt/applications/workbench/workbench/plotting/figuremanager.py +++ b/qt/applications/workbench/workbench/plotting/figuremanager.py @@ -137,7 +137,8 @@ class FigureManagerWorkbench(FigureManagerBase, QObject): if self.window._destroying: return self.window._destroying = True - map(self.canvas.mpl_disconnect, self._cids) + for id in self._cids: + self.canvas.mpl_disconnect(id) try: Gcf.destroy(self.num) except AttributeError: diff --git a/qt/applications/workbench/workbench/plotting/functions.py b/qt/applications/workbench/workbench/plotting/functions.py index fa68140fa08..cc1e6c6dc34 100644 --- a/qt/applications/workbench/workbench/plotting/functions.py +++ b/qt/applications/workbench/workbench/plotting/functions.py @@ -218,8 +218,8 @@ def pcolormesh(workspaces, fig=None): ws = workspaces[subplot_idx] ax.set_title(ws.name()) pcm = ax.pcolormesh(ws, cmap=DEFAULT_COLORMAP) - xticks = ax.get_xticklabels() - map(lambda lbl: lbl.set_rotation(45), xticks) + for lbl in ax.get_xticklabels(): + lbl.set_rotation(45) if col_idx < ncols - 1: col_idx += 1 else: -- GitLab