Skip to content

Commit

Permalink
Merge pull request #2344 from astrofrog/misc-fixes-reprojection
Browse files Browse the repository at this point in the history
Fix issues that came up while testing on-the-fly reprojection
  • Loading branch information
astrofrog authored Apr 3, 2023
2 parents 08497fd + 59e76ed commit da68d1a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
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:

This comment has been minimized.

Copy link
@pllim

pllim Apr 6, 2023

Contributor

This particular change broke viewer.state.slices in Jdaviz: spacetelescope/jdaviz#2135

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

0 comments on commit da68d1a

Please sign in to comment.