Skip to content

Commit

Permalink
fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Jan 2, 2025
1 parent 38008fe commit 7e6d924
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
6 changes: 1 addition & 5 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ def set_data_visibility(self, viewer_reference, data_label, visible=True, replac
# if Data has children, update their visibilities to match Data:
available_plugins = [tray_item['name'] for tray_item in self.state.tray_items]
for child in assoc_children:
if child not in viewer.data_labels_loaded:
if child not in viewer.data_menu.data_labels_loaded:
self.add_data_to_viewer(viewer.reference, child, visible=visible)

if 'g-data-quality' in available_plugins and visible:
Expand Down Expand Up @@ -2694,10 +2694,6 @@ def _on_new_viewer(self, msg, vid=None, name=None, add_layers_to_viewer=False,
linked_by_wcs = False
viewer.state.linked_by_wcs = linked_by_wcs

if linked_by_wcs:
from jdaviz.configs.imviz.helper import get_wcs_only_layer_labels
viewer.state.wcs_only_layers = get_wcs_only_layer_labels(self)

if msg.x_attr is not None:
x = msg.data.id[msg.x_attr]
viewer.state.x_att = x
Expand Down
12 changes: 5 additions & 7 deletions jdaviz/configs/imviz/plugins/orientation/orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
PluginTemplateMixin, SelectPluginComponent, LayerSelect, ViewerSelectMixin, AutoTextField
)
from jdaviz.core.user_api import PluginUserApi
from jdaviz.utils import get_reference_image_data, layer_is_2d, _wcs_only_label
from jdaviz.utils import (get_wcs_only_layer_labels, get_reference_image_data,
layer_is_2d, _wcs_only_label)

__all__ = ['Orientation']

Expand Down Expand Up @@ -419,10 +420,7 @@ def _add_orientation(self, rotation_angle=None, east_left=None, label=None,
self.orientation.selected = label

def _add_data_to_viewer(self, data_label, viewer_id):
viewer = self.app.get_viewer_by_id(viewer_id)

wcs_only_layers = viewer.state.wcs_only_layers
if data_label not in wcs_only_layers:
if data_label not in get_wcs_only_layer_labels(self.app):
self.app.add_data_to_viewer(viewer_id, data_label)

def _on_viewer_added(self, msg):
Expand All @@ -433,7 +431,7 @@ def _send_wcs_layers_to_all_viewers(self, *args, **kwargs):
if not hasattr(self, 'viewer'):
return

wcs_only_layers = self.app._jdaviz_helper.default_viewer._obj.state.wcs_only_layers
wcs_only_layers = get_wcs_only_layer_labels(self.app)

viewers_to_update = kwargs.get(
'viewers_to_update', self.app._viewer_store.keys()
Expand All @@ -446,7 +444,7 @@ def _send_wcs_layers_to_all_viewers(self, *args, **kwargs):
self.app.add_data_to_viewer(viewer_ref, wcs_layer)
if (
self.orientation.selected not in
self.viewer.selected_obj.state.wcs_only_layers and
wcs_only_layers and
self.align_by_selected == 'WCS'
):
self.orientation.selected = base_wcs_layer_label
Expand Down
5 changes: 3 additions & 2 deletions jdaviz/configs/imviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from jdaviz.core.registries import viewer_registry
from jdaviz.core.freezable_state import FreezableBqplotImageViewerState
from jdaviz.configs.default.plugins.viewers import JdavizViewerMixin
from jdaviz.utils import data_has_valid_wcs, layer_is_image_data, get_top_layer_index
from jdaviz.utils import (get_wcs_only_layer_labels, data_has_valid_wcs,
layer_is_image_data, get_top_layer_index)

__all__ = ['ImvizImageView']

Expand Down Expand Up @@ -318,7 +319,7 @@ def get_alignment_method(self, data_label):
if data_label == ref_label:
return 'self'

if ref_label in self.state.wcs_only_layers:
if ref_label in get_wcs_only_layer_labels(self.app):
return 'wcs'

align_by = None
Expand Down
8 changes: 5 additions & 3 deletions jdaviz/configs/imviz/tests/test_wcs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ class TestWCSOnly(BaseImviz_WCS_GWCS):

# TODO: Replace private API calls with more public ones when available.
def test_non_wcs_layer_labels(self):
from jdaviz.utils import get_wcs_only_layer_labels

self.imviz.link_data(align_by="wcs")
assert len(self.imviz.app.data_collection) == 3

# Confirm the WCS-only layer is created by WCS-linking .
assert len(self.viewer.state.wcs_only_layers) == 1
assert len(get_wcs_only_layer_labels(self.imviz.app)) == 1

# Load a WCS-only layer, bypassing normal labeling scheme.
ndd = wcs_utils._get_rotated_nddata_from_label(
Expand All @@ -133,7 +135,7 @@ def test_non_wcs_layer_labels(self):
assert len(self.imviz.app.state.layer_icons) == 4 # 3 + 1

# Confirm the new WCS-only layer is logged.
assert len(self.viewer.state.wcs_only_layers) == 2
assert len(get_wcs_only_layer_labels(self.imviz.app)) == 2

# Load a second WCS-only layer.
ndd2 = wcs_utils._get_rotated_nddata_from_label(
Expand All @@ -149,7 +151,7 @@ def test_non_wcs_layer_labels(self):
assert len(self.imviz.app.state.layer_icons) == 5

# Confirm the second WCS-only layer is logged
assert len(self.viewer.state.wcs_only_layers) == 3
assert len(get_wcs_only_layer_labels(self.imviz.app)) == 3

# First entry is image data and the default reference data.
assert self.imviz.app.state.layer_icons["fits_wcs[DATA]"] == "a"
Expand Down

0 comments on commit 7e6d924

Please sign in to comment.