Skip to content

Commit

Permalink
handle case where no data loaded in viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Mar 2, 2023
1 parent 22c0811 commit 5a0d495
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion jdaviz/configs/imviz/plugins/rotate_canvas/rotate_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def user_api(self):

@property
def ref_data(self):
return list(self.app.get_data_from_viewer(self.viewer_selected).values())[0]
data = list(self.app.get_data_from_viewer(self.viewer_selected).values())
return data[0] if len(data) else None

def _on_viewer_data_changed(self, msg=None):
if not self.viewer_selected: # pragma: no cover
Expand All @@ -65,6 +66,8 @@ def _get_wcs_angles(self):
if not self.has_wcs:
raise ValueError("reference data does not have WCS, cannot determine orientation")
ref_data = self.ref_data
if ref_data is None: # pragma: no cover
raise ValueError("no data loaded in viewer, cannot determine orientation")
_, _, _, _, _, _, degn, dege, flip = get_compass_info(ref_data.wcs, ref_data.data.shape)
return degn, dege, flip

Expand Down

0 comments on commit 5a0d495

Please sign in to comment.