From 857581e4fecbdbb3a8febc67f3671f1a640a65f8 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Mon, 7 Aug 2017 14:59:41 +0100 Subject: [PATCH 01/11] Broadcast a message when a layer is enabled or disabled, which then will allow the layer list to refresh --- glue/core/layer_artist.py | 8 +++++++- glue/core/message.py | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/glue/core/layer_artist.py b/glue/core/layer_artist.py index 489caea00..7b7507c60 100644 --- a/glue/core/layer_artist.py +++ b/glue/core/layer_artist.py @@ -20,7 +20,7 @@ from glue.external import six from glue.core.subset import Subset from glue.utils import Pointer, PropertySetMixin - +from glue.core.message import LayerArtistEnabledMessage, LayerArtistDisabledMessage __all__ = ['LayerArtistBase', 'MatplotlibLayerArtist', 'LayerArtistContainer'] @@ -89,6 +89,9 @@ def enable(self): self._disabled_reason = '' self._enabled = True self.redraw() + if self._layer is not None and self._layer.hub is not None: + message = LayerArtistEnabledMessage(self) + self._layer.hub.broadcast(message) def disable(self, reason): """ @@ -106,6 +109,9 @@ def disable(self, reason): self._disabled_reason = reason self._enabled = False self.clear() + if self._layer is not None and self._layer.hub is not None: + message = LayerArtistDisabledMessage(self) + self._layer.hub.broadcast(message) def disable_invalid_attributes(self, *attributes): """ diff --git a/glue/core/message.py b/glue/core/message.py index f26cf0cc5..272ab0d46 100644 --- a/glue/core/message.py +++ b/glue/core/message.py @@ -11,7 +11,8 @@ 'DataCollectionMessage', 'DataCollectionActiveChange', 'DataCollectionActiveDataChange', 'DataCollectionAddMessage', 'DataCollectionDeleteMessage', 'ApplicationClosedMessage', - 'DataRemoveComponentMessage'] + 'DataRemoveComponentMessage', 'LayerArtistEnabledMessage', + 'LayerArtistDisabledMessage'] class Message(object): @@ -204,3 +205,15 @@ def __init__(self, sender, settings, tag=None): class ApplicationClosedMessage(Message): """A general message issued when Glue application is closed.""" pass + + +class LayerArtistEnabledMessage(Message): + def __init__(self, sender, tag=None): + super(LayerArtistEnabledMessage, self).__init__(sender, tag=tag) + self.layer_artist = self.sender + + +class LayerArtistDisabledMessage(Message): + def __init__(self, sender, tag=None): + super(LayerArtistDisabledMessage, self).__init__(sender, tag=tag) + self.layer_artist = self.sender From 2ab32d786550cc9952ea02cd16891f2ebca61e55 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 8 Aug 2017 11:27:48 +0100 Subject: [PATCH 02/11] Make layer artist disabled/unselectable if it has been disabled due to e.g. incompatible attributes --- glue/core/qt/layer_artist_model.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/glue/core/qt/layer_artist_model.py b/glue/core/qt/layer_artist_model.py index 3e80229c5..bb97fea2f 100644 --- a/glue/core/qt/layer_artist_model.py +++ b/glue/core/qt/layer_artist_model.py @@ -62,10 +62,17 @@ def data(self, index, role): def flags(self, index): result = super(LayerArtistModel, self).flags(index) if index.isValid(): - result = (result | Qt.ItemIsEditable | Qt.ItemIsDragEnabled | - Qt.ItemIsUserCheckable) + art = self.artists[index.row()] + print('flags', art.enabled) + if art.enabled: + result = (result | Qt.ItemIsEditable | Qt.ItemIsDragEnabled | + Qt.ItemIsUserCheckable) + else: + result = (result & Qt.ItemIsEnabled) ^ result + result = (result & Qt.ItemIsSelectable) ^ result + result = (result & Qt.ItemIsUserCheckable) ^ result else: # only drop between rows, where index isn't valid - result = (result | Qt.ItemIsDropEnabled) + result = result | Qt.ItemIsDropEnabled return result @@ -216,7 +223,6 @@ def rowsInserted(self, index, start, end): def selectionChanged(self, selected, deselected): super(LayerArtistView, self).selectionChanged(selected, deselected) - self._update_actions() parent = self.parent() if parent is not None: parent.on_selection_change(self.current_artist()) @@ -242,9 +248,6 @@ def current_row(self): return return rows[0].row() - def _update_actions(self): - pass - def _bottom_left_of_current_index(self): idx = self.currentIndex() if not idx.isValid(): From c4c8f7e1a98ccc6ac415df6db8c65d5b8db70e11 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 8 Aug 2017 11:32:19 +0100 Subject: [PATCH 03/11] Only call on_selection_change manually if a message pertaining to enabled or disabled layers is called. --- glue/core/qt/layer_artist_model.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/glue/core/qt/layer_artist_model.py b/glue/core/qt/layer_artist_model.py index bb97fea2f..b780b4112 100644 --- a/glue/core/qt/layer_artist_model.py +++ b/glue/core/qt/layer_artist_model.py @@ -22,7 +22,7 @@ from glue.utils import nonpartial from glue.utils.qt import PythonListModel, PyMimeData from glue.core.hub import HubListener -from glue.core.message import Message +from glue.core.message import Message, LayerArtistEnabledMessage, LayerArtistDisabledMessage class LayerArtistModel(PythonListModel): @@ -63,7 +63,6 @@ def flags(self, index): result = super(LayerArtistModel, self).flags(index) if index.isValid(): art = self.artists[index.row()] - print('flags', art.enabled) if art.enabled: result = (result | Qt.ItemIsEditable | Qt.ItemIsDragEnabled | Qt.ItemIsUserCheckable) @@ -204,12 +203,30 @@ def __init__(self, parent=None, hub=None): # listen to all events since the viewport update is fast. self.hub = hub self.hub.subscribe(self, Message, self._update_viewport) + self.hub.subscribe(self, LayerArtistEnabledMessage, self._layer_enabled_or_disabled) + self.hub.subscribe(self, LayerArtistDisabledMessage, self._layer_enabled_or_disabled) def _update_viewport(self, *args): + # This forces the widget containing the list view to update/redraw, # reflecting any changes in color/labels/content self.viewport().update() + def _layer_enabled_or_disabled(self, *args): + + # This forces the widget containing the list view to update/redraw, + # reflecting any changes in disabled/enabled layers. If a layer is + # disabled, it will become unselected. + self.viewport().update() + + # If a layer artist becomes unselected as a result of the update above, + # a selection change event is not emitted for some reason, so we force + # a manual update. If a layer artist was deselected, current_artist() + # will be None and the options will be hidden for that layer. + parent = self.parent() + if parent is not None: + parent.on_selection_change(self.current_artist()) + def rowsInserted(self, index, start, end): super(LayerArtistView, self).rowsInserted(index, start, end) # If no rows are currently selected, make sure we select one. We do From b0069a37873a837c7f94289c4c70cf7c5da1bca1 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 8 Aug 2017 12:35:14 +0100 Subject: [PATCH 04/11] Make set_multiple_data deal with duplicate datasets and subsets --- glue/core/data_combo_helper.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/glue/core/data_combo_helper.py b/glue/core/data_combo_helper.py index 9dc8d08bd..9db8cdb80 100644 --- a/glue/core/data_combo_helper.py +++ b/glue/core/data_combo_helper.py @@ -5,7 +5,7 @@ import weakref -from glue.core import Subset +from glue.core import Data, Subset from glue.core.hub import HubListener from glue.core.message import (ComponentsChangedMessage, DataCollectionAddMessage, @@ -19,6 +19,22 @@ 'DataCollectionComboHelper'] +def unique_data_iter(datasets): + """ + Return a list with only Data objects, with duplicates removed, but + preserving the original order. + """ + datasets_new = [] + for dataset in datasets: + if isinstance(dataset, Data): + if dataset not in datasets_new: + datasets_new.append(dataset) + else: + if dataset.data not in datasets_new: + datasets_new.append(dataset) + return datasets_new + + class ComboHelper(HubListener): """ Base class for any combo helper represented by a SelectionCallbackProperty. @@ -250,7 +266,7 @@ def set_multiple_data(self, datasets): self._data.clear() except AttributeError: # PY2 self._data[:] = [] - for data in datasets: + for data in unique_data_iter(datasets): self.append_data(data, refresh=False) self.refresh() @@ -423,7 +439,7 @@ def set_multiple_data(self, datasets): self._datasets.clear() except AttributeError: # PY2 self._datasets[:] = [] - for data in datasets: + for data in unique_data_iter(datasets): self._datasets.append(data) self.refresh() From 5e42ca2c19d643eb032d83a50705ee8735af1a26 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 8 Aug 2017 12:35:45 +0100 Subject: [PATCH 05/11] Only set label in data wizard if not already set by readers --- glue/dialogs/data_wizard/qt/data_wizard_dialog.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glue/dialogs/data_wizard/qt/data_wizard_dialog.py b/glue/dialogs/data_wizard/qt/data_wizard_dialog.py index eb92da2f9..1bffa19d2 100644 --- a/glue/dialogs/data_wizard/qt/data_wizard_dialog.py +++ b/glue/dialogs/data_wizard/qt/data_wizard_dialog.py @@ -120,7 +120,8 @@ def load_data(self): self._curfile = path d = load_data(path, factory=fac.function) if not isinstance(d, list): - d.label = data_label(path) + if not d.label: + d.label = data_label(path) d = [d] result.extend(d) From 150fcc048be678d10f423cc6cdabbf61c328811f Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 8 Aug 2017 12:36:03 +0100 Subject: [PATCH 06/11] Add default status tip for all ROI selection modes --- glue/viewers/common/qt/mouse_mode.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/glue/viewers/common/qt/mouse_mode.py b/glue/viewers/common/qt/mouse_mode.py index 041b3aab7..f5a5d6710 100644 --- a/glue/viewers/common/qt/mouse_mode.py +++ b/glue/viewers/common/qt/mouse_mode.py @@ -196,6 +196,8 @@ class RoiMode(RoiModeBase): mouse release """ + status_tip = "CLICK and DRAG to define selection" + def __init__(self, viewer, **kwargs): super(RoiMode, self).__init__(viewer, **kwargs) From 088e0a935f7b0fc4b1e8511fd83f0f7fb2b53f88 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 8 Aug 2017 12:37:01 +0100 Subject: [PATCH 07/11] Make sure that if a dataset is added multiple times to an image viewer, we disable global syncing for those specific layers. Also make use of the improved set_multiple_data behavior to simplify code. --- glue/viewers/histogram/state.py | 10 +----- glue/viewers/image/state.py | 53 +++++++++++++++++++++++--------- glue/viewers/matplotlib/state.py | 4 +++ glue/viewers/scatter/state.py | 17 ++-------- 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/glue/viewers/histogram/state.py b/glue/viewers/histogram/state.py index 08cc16adc..3d2465db1 100644 --- a/glue/viewers/histogram/state.py +++ b/glue/viewers/histogram/state.py @@ -122,15 +122,7 @@ def bins(self): @defer_draw def _layers_changed(self, *args): - datasets = [] - for layer in self.layers: - if isinstance(layer.layer, Data): - if layer.layer not in datasets: - datasets.append(layer.layer) - else: - if layer.layer.data not in datasets: - datasets.append(layer.layer.data) - self.x_att_helper.set_multiple_data(datasets) + self.x_att_helper.set_multiple_data(self.layers_data) class HistogramLayerState(MatplotlibLayerState): diff --git a/glue/viewers/image/state.py b/glue/viewers/image/state.py index 25c8d164c..0732b1dc6 100644 --- a/glue/viewers/image/state.py +++ b/glue/viewers/image/state.py @@ -1,5 +1,7 @@ from __future__ import absolute_import, division, print_function +from collections import defaultdict + from glue.core import Data from glue.config import colormaps from glue.viewers.matplotlib.state import (MatplotlibDataViewerState, @@ -91,21 +93,44 @@ def _reference_data_changed(self, *args): self._set_default_slices() def _layers_changed(self, *args): + + # The layers callback gets executed if anything in the layers changes, + # but we only care about whether the actual set of 'layer' attributes + # for all layers change. + + layers_data = self.layers_data + layers_data_cache = getattr(self, '_layers_data_cache', []) + + if layers_data == layers_data_cache: + return + self._update_combo_ref_data() self._set_reference_data() + self._update_syncing() - def _update_combo_ref_data(self, *args): - datasets = [] - for layer in self.layers: - if isinstance(layer.layer, Data): - if layer.layer not in datasets: - datasets.append(layer.layer) - else: - if layer.layer.data not in datasets: - datasets.append(layer.layer.data) - self.ref_data_helper.set_multiple_data(datasets) + self._layers_data_cache = layers_data + + def _update_syncing(self): + + # If there are multiple layers for a given dataset, we disable the + # syncing by default. + + layer_state_by_data = defaultdict(list) + + for layer_state in self.layers: + if isinstance(layer_state.layer, Data): + layer_state_by_data[layer_state.layer].append(layer_state) + + for data, layer_states in layer_state_by_data.items(): + if len(layer_states) > 1: + for layer_state in layer_states: + if layer_state.global_sync: + layer_state.global_sync = False + + def _update_combo_ref_data(self): + self.ref_data_helper.set_multiple_data(self.layers_data) - def _update_combo_att(self, *args): + def _update_combo_att(self): with delay_callback(self, 'x_att_world', 'y_att_world'): if self.reference_data is None: self.xw_att_helper.set_multiple_data([]) @@ -165,16 +190,14 @@ def _on_yatt_world_change(self, *args): else: self.x_att_world = world_ids[-1] - def _set_reference_data(self, *args): - # TODO: make sure this doesn't get called for changes *in* the layers - # for list callbacks maybe just have an event for length change in list + def _set_reference_data(self): if self.reference_data is None: for layer in self.layers: if isinstance(layer.layer, Data): self.reference_data = layer.layer return - def _set_default_slices(self, *args): + def _set_default_slices(self): # Need to make sure this gets called immediately when reference_data is changed if self.reference_data is None: self.slices = () diff --git a/glue/viewers/matplotlib/state.py b/glue/viewers/matplotlib/state.py index 730c02480..6157d1a1b 100644 --- a/glue/viewers/matplotlib/state.py +++ b/glue/viewers/matplotlib/state.py @@ -52,6 +52,10 @@ class MatplotlibDataViewerState(State): layers = ListCallbackProperty(docstring='A collection of all layers in the viewer') + @property + def layers_data(self): + return [layer_state.layer for layer_state in self.layers] + class MatplotlibLayerState(State): """ diff --git a/glue/viewers/scatter/state.py b/glue/viewers/scatter/state.py index d96966f4f..9b10f0bb6 100644 --- a/glue/viewers/scatter/state.py +++ b/glue/viewers/scatter/state.py @@ -94,21 +94,8 @@ def _get_components(self, cid): return components def _layers_changed(self, *args): - - layers = [] - - for layer_state in self.layers: - if isinstance(layer_state.layer, Data): - if layer_state.layer not in layers: - layers.append(layer_state.layer) - - for layer_state in self.layers: - if isinstance(layer_state.layer, Subset) and layer_state.layer.data not in layers: - if layer_state.layer not in layers: - layers.append(layer_state.layer) - - self.x_att_helper.set_multiple_data(layers) - self.y_att_helper.set_multiple_data(layers) + self.x_att_helper.set_multiple_data(self.layers_data) + self.y_att_helper.set_multiple_data(self.layers_data) class ScatterLayerState(MatplotlibLayerState): From 839454efcb32b3d2bf918f1294d6c247e2caf847 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 8 Aug 2017 12:37:48 +0100 Subject: [PATCH 08/11] Improve layer icons to support colormaps and to show the color of the layer artist, not the global data color (since they are not always in sync) --- glue/core/layer_artist.py | 6 ++++++ glue/icons/qt/helpers.py | 23 ++++++++++++++--------- glue/viewers/image/layer_artist.py | 6 ++++++ glue/viewers/matplotlib/layer_artist.py | 3 +++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/glue/core/layer_artist.py b/glue/core/layer_artist.py index 7b7507c60..115786871 100644 --- a/glue/core/layer_artist.py +++ b/glue/core/layer_artist.py @@ -83,6 +83,12 @@ def __init__(self, layer): self._disabled_reason = '' # A string explaining why this layer is disabled. + def get_layer_color(self): + # This method can return either a plain color or a colormap. This is + # used by the UI layer to determine a 'representative' color or colormap + # for the layer to be used e.g. in icons. + return self._layer.style.color + def enable(self): if self.enabled: return diff --git a/glue/icons/qt/helpers.py b/glue/icons/qt/helpers.py index dc1e456b3..46c003888 100644 --- a/glue/icons/qt/helpers.py +++ b/glue/icons/qt/helpers.py @@ -2,8 +2,10 @@ from qtpy.QtCore import Qt from qtpy import QtWidgets, QtGui -from glue.utils.qt import mpl_to_qt4_color, tint_pixmap +from matplotlib.colors import Colormap + +from glue.utils.qt import mpl_to_qt4_color, tint_pixmap, cmap2pixmap from glue.icons import icon_path __all__ = ['symbol_icon', 'layer_icon', 'layer_artist_icon', 'get_icon', 'POINT_ICONS'] @@ -47,16 +49,19 @@ def layer_artist_icon(artist): from glue.viewers.scatter.layer_artist import ScatterLayerArtist - if not artist.enabled: - bm = QtGui.QBitmap(icon_path('glue_delete')) - elif isinstance(artist, ScatterLayerArtist): - bm = QtGui.QBitmap(icon_path(POINT_ICONS.get(artist.layer.style.marker, - 'glue_circle_point'))) + color = artist.get_layer_color() + + if isinstance(color, Colormap): + pm = cmap2pixmap(color) else: - bm = QtGui.QBitmap(icon_path('glue_box_point')) - color = mpl_to_qt4_color(artist.layer.style.color) + if isinstance(artist, ScatterLayerArtist): + bm = QtGui.QBitmap(icon_path(POINT_ICONS.get(artist.layer.style.marker, + 'glue_circle_point'))) + else: + bm = QtGui.QBitmap(icon_path('glue_box_point')) + color = mpl_to_qt4_color(color) + pm = tint_pixmap(bm, color) - pm = tint_pixmap(bm, color) return QtGui.QIcon(pm) diff --git a/glue/viewers/image/layer_artist.py b/glue/viewers/image/layer_artist.py index 66b90f3e0..e692a1f70 100644 --- a/glue/viewers/image/layer_artist.py +++ b/glue/viewers/image/layer_artist.py @@ -122,6 +122,12 @@ def __init__(self, axes, viewer_state, layer_state=None, layer=None): shape=self.get_image_shape) self.composite_image = self.axes._composite_image + def get_layer_color(self): + if self._viewer_state.color_mode == 'One color per layer': + return self.state.color + else: + return self.state.cmap + def enable(self): if hasattr(self, 'composite_image'): self.composite_image.invalidate_cache() diff --git a/glue/viewers/matplotlib/layer_artist.py b/glue/viewers/matplotlib/layer_artist.py index 8e2efddb3..36ea75866 100644 --- a/glue/viewers/matplotlib/layer_artist.py +++ b/glue/viewers/matplotlib/layer_artist.py @@ -48,6 +48,9 @@ def remove(self): except ValueError: # already removed pass + def get_layer_color(self): + return self.state.color + def redraw(self): self.axes.figure.canvas.draw() From c96dc3a6a2b2ffa444ac5f96c2984794b9024cfc Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 8 Aug 2017 12:40:25 +0100 Subject: [PATCH 09/11] Added changelog entries --- CHANGES.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 4e4951a1a..21aa4aafb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,15 @@ Full changelog v0.11.0 (unreleased) -------------------- +* Disabled layer artists can no longer be selected to avoid any confusion. [#1367] + +* Layer artist icons can now show colormaps when appropriate. [#1367] + +* Fix behavior of data wizard so that it doesn't overwrite labels set by data + factories. [#1367] + +* Add a status tip for all ROI selection tools. [#1367] + * Fixed a bug that caused the terminal to not be available after resetting or opening a session. [#1366] From 57afe6e1dcd9c3271b273956f65e0512798900a2 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 8 Aug 2017 13:23:59 +0100 Subject: [PATCH 10/11] Fix typo in unique_data_iter --- glue/core/data_combo_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glue/core/data_combo_helper.py b/glue/core/data_combo_helper.py index 9db8cdb80..7e3a7d571 100644 --- a/glue/core/data_combo_helper.py +++ b/glue/core/data_combo_helper.py @@ -31,7 +31,7 @@ def unique_data_iter(datasets): datasets_new.append(dataset) else: if dataset.data not in datasets_new: - datasets_new.append(dataset) + datasets_new.append(dataset.data) return datasets_new From 4f9104dfce63dd5a2036429a83fd4177f297b2cd Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 8 Aug 2017 14:21:50 +0100 Subject: [PATCH 11/11] Fix tests --- glue/core/qt/tests/test_layer_artist_model.py | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/glue/core/qt/tests/test_layer_artist_model.py b/glue/core/qt/tests/test_layer_artist_model.py index d450d922f..c1f5a5252 100644 --- a/glue/core/qt/tests/test_layer_artist_model.py +++ b/glue/core/qt/tests/test_layer_artist_model.py @@ -5,7 +5,7 @@ from qtpy.QtCore import Qt from qtpy import PYQT5 from glue.core import Data, Hub -from glue.core.layer_artist import MatplotlibLayerArtist as _LayerArtist +from glue.core.layer_artist import LayerArtistBase as _LayerArtist from ..layer_artist_model import LayerArtistModel, LayerArtistView @@ -15,10 +15,15 @@ class LayerArtist(_LayerArtist): def update(self, view=None): pass + def clear(self): + pass + + def redraw(self): + pass + def setup_model(num): - ax = MagicMock() - mgrs = [LayerArtist(Data(label=str(i)), ax) for i in range(num)] + mgrs = [LayerArtist(Data(label=str(i))) for i in range(num)] model = LayerArtistModel(mgrs) return model, mgrs @@ -35,16 +40,16 @@ def test_row_label(): def test_add_artist_updates_row_count(): - mgrs = [LayerArtist(Data(label='A'), None)] + mgrs = [LayerArtist(Data(label='A'))] model = LayerArtistModel(mgrs) - model.add_artist(0, LayerArtist(Data(label='B'), None)) + model.add_artist(0, LayerArtist(Data(label='B'))) assert model.rowCount() == 2 def test_add_artist_updates_artist_list(): - mgrs = [LayerArtist(Data(label='A'), None)] + mgrs = [LayerArtist(Data(label='A'))] model = LayerArtistModel(mgrs) - model.add_artist(0, LayerArtist(Data(label='B'), None)) + model.add_artist(0, LayerArtist(Data(label='B'))) assert len(mgrs) == 2 @@ -92,7 +97,7 @@ def test_change_label_invalid_row(): def test_flags(): - model, _ = setup_model(1) + model, layer_artists = setup_model(1) expected = (Qt.ItemIsEditable | Qt.ItemIsDragEnabled | @@ -115,8 +120,7 @@ def test_move_artist_empty(): def test_move_artist_single(): - ax = MagicMock() - m0 = LayerArtist(Data(label="test 0"), ax) + m0 = LayerArtist(Data(label="test 0")) mgrs = [m0] model = LayerArtistModel(mgrs) @@ -170,9 +174,9 @@ def test_move_artist_three(): def test_move_updates_zorder(): - m0 = LayerArtist(Data(label='test 0'), MagicMock()) - m1 = LayerArtist(Data(label='test 1'), MagicMock()) - m2 = LayerArtist(Data(label='test 2'), MagicMock()) + m0 = LayerArtist(Data(label='test 0')) + m1 = LayerArtist(Data(label='test 1')) + m2 = LayerArtist(Data(label='test 2')) m0.zorder = 10 m1.zorder = 20 m2.zorder = 30 @@ -187,7 +191,7 @@ def test_move_updates_zorder(): def test_check_syncs_to_visible(): - m0 = LayerArtist(Data(label='test 0'), MagicMock()) + m0 = LayerArtist(Data(label='test 0')) m0.artists = [MagicMock()] mgrs = [m0] model = LayerArtistModel(mgrs)