Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Jan 18, 2024
1 parent fcd4905 commit 7135855
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from glue_jupyter.bqplot.image import BqplotImageView
from glue_jupyter.registries import viewer_registry
from glue_jupyter.widgets.linked_dropdown import get_choices as _get_glue_choices
from regions import PixelRegion
from specutils import Spectrum1D
from specutils.manipulation import extract_region
from traitlets import Any, Bool, Float, HasTraits, List, Unicode, observe
Expand All @@ -46,7 +47,8 @@
LineAnalysisContinuumCenter,
LineAnalysisContinuumLeft,
LineAnalysisContinuumRight,
ShadowLine)
ShadowLine, ApertureMark)
from jdaviz.core.region_translators import regions2roi
from jdaviz.core.region_translators import _get_region_from_spatial_subset
from jdaviz.core.user_api import UserApiWrapper, PluginUserApi
from jdaviz.style_registry import PopoutStyleWrapper
Expand Down Expand Up @@ -1957,16 +1959,13 @@ def _plugin_active_changed(self, *args):

@property
def image_viewers(self):
# TODO: iterator?
from glue_jupyter.bqplot.image import BqplotImageView

return [viewer for viewer in self.app._viewer_store.values() if isinstance(viewer, BqplotImageView)]
return [viewer for viewer in self.app._viewer_store.values()
if isinstance(viewer, BqplotImageView)]

@property
def marks(self):
# TODO: support multiple ApertureSubsetSelect per-plugin (only retrieve those belonging to this one)
from jdaviz.core.marks import ApertureMark

# NOTE: this will require additional logic if we want to support multiple independent
# ApertureSubsetSelect instances per-plugin
all_aperture_marks = []
for viewer in self.image_viewers:
# search for existing mark
Expand All @@ -1990,16 +1989,14 @@ def marks(self):
return all_aperture_marks

def _get_mark_coords(self, viewer):
from jdaviz.core.region_translators import regions2roi
from regions import PixelRegion

if not len(self.selected) or not len(self.dataset.selected):
return [], []

if self.multiselect:
# assume first dataset (for retrieving the region object)
# but iterate over all subsets
spatial_regions = [self._get_spatial_region(dataset=self.dataset.selected[0], subset=subset) for subset in self.selected]
spatial_regions = [self._get_spatial_region(dataset=self.dataset.selected[0], subset=subset) # noqa
for subset in self.selected]
else:
# use cached version
spatial_regions = [self.selected_spatial_region]
Expand Down Expand Up @@ -2064,8 +2061,8 @@ def __init__(self, *args, **kwargs):
'aperture_items',
'aperture_selected',
'aperture_radius_factor',
dataset='dataset' if hasattr(self, 'dataset') else None,
multiselect='multiselect' if hasattr(self, 'multiselect') else None)
dataset='dataset' if hasattr(self, 'dataset') else None, # noqa
multiselect='multiselect' if hasattr(self, 'multiselect') else None) # noqa


class DatasetSpectralSubsetValidMixin(VuetifyTemplate, HubListener):
Expand Down

0 comments on commit 7135855

Please sign in to comment.