From c66a2a6ebe653f951d8d720a12ccd25616e06ed6 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 17 Jul 2018 19:23:36 +0200 Subject: [PATCH 1/2] Remove some unnecessary calls to list(). --- examples/color/colormap_reference.py | 2 +- lib/matplotlib/backend_tools.py | 2 +- lib/matplotlib/backends/qt_editor/formlayout.py | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/color/colormap_reference.py b/examples/color/colormap_reference.py index e99dd25e678b..759e12609e9b 100644 --- a/examples/color/colormap_reference.py +++ b/examples/color/colormap_reference.py @@ -52,7 +52,7 @@ def plot_color_gradients(cmap_category, cmap_list, nrows): for ax, name in zip(axes, cmap_list): ax.imshow(gradient, aspect='auto', cmap=plt.get_cmap(name)) - pos = list(ax.get_position().bounds) + pos = ax.get_position().bounds x_text = pos[0] - 0.01 y_text = pos[1] + pos[3]/2. fig.text(x_text, y_text, name, va='center', ha='right', fontsize=10) diff --git a/lib/matplotlib/backend_tools.py b/lib/matplotlib/backend_tools.py index 50b021679694..a913dbaf6dc7 100644 --- a/lib/matplotlib/backend_tools.py +++ b/lib/matplotlib/backend_tools.py @@ -25,7 +25,7 @@ class Cursors(object): """Simple namespace for cursor reference""" - HAND, POINTER, SELECT_REGION, MOVE, WAIT = list(range(5)) + HAND, POINTER, SELECT_REGION, MOVE, WAIT = range(5) cursors = Cursors() # Views positions tool diff --git a/lib/matplotlib/backends/qt_editor/formlayout.py b/lib/matplotlib/backends/qt_editor/formlayout.py index ee2eb6beae10..1389cda1e309 100644 --- a/lib/matplotlib/backends/qt_editor/formlayout.py +++ b/lib/matplotlib/backends/qt_editor/formlayout.py @@ -243,10 +243,8 @@ def setup(self): elif isinstance(value, str): field = QtWidgets.QLineEdit(value, self) elif isinstance(value, (list, tuple)): - if isinstance(value, tuple): - value = list(value) - selindex = value.pop(0) field = QtWidgets.QComboBox(self) + selindex, *value = value if isinstance(value[0], (list, tuple)): keys = [key for key, _val in value] value = [val for _key, val in value] From 6138aa59a6935ebabb7ec7a12c3a271a99258d84 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 17 Jul 2018 23:29:06 +0200 Subject: [PATCH 2/2] Another super()-ification. --- lib/mpl_toolkits/axes_grid1/parasite_axes.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/mpl_toolkits/axes_grid1/parasite_axes.py b/lib/mpl_toolkits/axes_grid1/parasite_axes.py index bd8dd58a4e57..b7532c428ccc 100644 --- a/lib/mpl_toolkits/axes_grid1/parasite_axes.py +++ b/lib/mpl_toolkits/axes_grid1/parasite_axes.py @@ -59,11 +59,9 @@ def _get_base_axes_attr(self, attrname): class ParasiteAxesAuxTransBase(object): def __init__(self, parent_axes, aux_transform, viewlim_mode=None, **kwargs): - self.transAux = aux_transform self.set_viewlim_mode(viewlim_mode) - - self._parasite_axes_class.__init__(self, parent_axes, **kwargs) + super().__init__(parent_axes, **kwargs) def _set_lim_and_transforms(self): @@ -188,8 +186,7 @@ def parasite_axes_auxtrans_class_factory(axes_class=None): parasite_axes_class = axes_class return type("%sParasiteAuxTrans" % parasite_axes_class.__name__, (ParasiteAxesAuxTransBase, parasite_axes_class), - {'_parasite_axes_class': parasite_axes_class, - 'name': 'parasite_axes'}) + {'name': 'parasite_axes'}) ParasiteAxesAuxTrans = parasite_axes_auxtrans_class_factory(