Commit 385b56e3 authored by Alice Russell's avatar Alice Russell
Browse files

Re #27856 Apply suggested changes

Fix an issue where it modifying a list whilst iterating it.
Fix a failing test caused by rebasing
parent 9c9a69ce
......@@ -1041,22 +1041,22 @@ def update_colorbar_scale(figure, image, scale, vmin, vmax):
figure.subplots_adjust(wspace=0.5, hspace=0.5)
figure.colorbar(image, ax=figure.axes, ticks=locator, pad=0.06)
def get_images_from_figure(figure):
"""Return a list of images in the given figure excluding any colorbar images"""
axes = figure.get_axes()
images = []
all_images = []
for ax in axes:
images += ax.images + [col for col in ax.collections if isinstance(col, QuadMesh)
or isinstance(col, Poly3DCollection)]
all_images += ax.images + [col for col in ax.collections if isinstance(col, QuadMesh)
or isinstance(col, Poly3DCollection)]
# remove any colorbar images
for img in images:
if img.colorbar:
images.remove(img.colorbar.solids)
colorbars = [img.colorbar.solids for img in all_images if img.colorbar]
images = [img for img in all_images if img not in colorbars]
return images
def get_axes_from_figure(figure):
"""Return a list of axes in the given figure excluding any colorbar axes"""
images = get_images_from_figure(figure)
......
......@@ -195,7 +195,7 @@ class ImagesTabWidgetPresenterTest(unittest.TestCase):
'vmax': 2,
'scale': 'Linear',
'interpolation': 'None'}
mock_view = Mock(get_selected_image_name=lambda: '(0, 0)',
mock_view = Mock(get_selected_image_name=lambda: 'ws: (0, 0)',
get_properties=lambda: ImageProperties(props))
presenter = self._generate_presenter(fig=fig, view=mock_view)
presenter.apply_properties()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment