Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs related to generic BaseCartesianData subclasses #2344

Merged
merged 4 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion glue/core/data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def __setitem__(self, key, data):
if not isinstance(key, str):
raise TypeError("item key should be a string, but got {0}".format(type(key)))

if not isinstance(data, Data):
if not isinstance(data, BaseCartesianData):

handler, preferred = data_translator.get_handler_for(data)

Expand Down
4 changes: 3 additions & 1 deletion glue/viewers/common/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ class BaseViewer(HubListener):
The base class for all viewers.
"""

LABEL = 'Override this'
LABEL = None

def __init__(self, session):
self._session = session
self._data = session.data_collection
self._hub = None
if self.LABEL is None:
self.LABEL = str(self.__class__)

def register_to_hub(self, hub):
self._hub = hub
Expand Down
4 changes: 2 additions & 2 deletions glue/viewers/image/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ def reset_limits(self):
def _display_world(self):
return getattr(self.reference_data, 'coords', None) is not None

def _reference_data_changed(self, *args):
def _reference_data_changed(self, *args, force=False):
# This signal can get emitted if just the choices but not the actual
# reference data change, so we check here that the reference data has
# actually changed
if self.reference_data is not getattr(self, '_last_reference_data', None):
if self.reference_data is not getattr(self, '_last_reference_data', None) or force:
self._last_reference_data = self.reference_data
# Note that we deliberately use nested delay_callback here, because
# we want to make sure that x_att_world and y_att_world both get
Expand Down
4 changes: 4 additions & 0 deletions glue/viewers/image/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def add_data(self, data):
self._set_wcs()
return result

def _update_data(self, *args, **kwargs):
super()._update_data(*args, **kwargs)
self.state._reference_data_changed(force=True)

def _on_slice_change(self, event=None):
if self._changing_slice_requires_wcs_update:
self._set_wcs(relim=False)
Expand Down