Skip to content

Commit

Permalink
Pull in spacetelescope#2204 into this PR
Browse files Browse the repository at this point in the history
and bump upstream pins
  • Loading branch information
pllim committed Jun 21, 2023
1 parent 579d4bb commit d068130
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
32 changes: 3 additions & 29 deletions jdaviz/configs/default/plugins/subset_plugin/subset_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from glue.core.edit_subset_mode import (AndMode, AndNotMode, OrMode,
ReplaceMode, XorMode)
from glue.core.roi import CircularROI, CircularAnnulusROI, EllipticalROI, RectangularROI
from glue.core.subset import RoiSubsetState, RangeSubsetState, CompositeSubsetState
from glue.core.subset import RoiSubsetState, RangeSubsetState
from glue.icons import icon_path
from glue_jupyter.widgets.subset_mode_vuetify import SelectionModeMenu
from glue_jupyter.common.toolbar_vuetify import read_icon
Expand Down Expand Up @@ -385,39 +385,13 @@ def get_center(self):
depending on the Subset type, if applicable.
If Subset is not centerable, this returns `None`.
Raises
------
NotImplementedError
Subset type is not supported.
"""
# Composite region cannot be centered.
if not self.is_centerable: # no-op
return

subset_state = self.subset_select.selected_subset_state

if isinstance(subset_state, RoiSubsetState):
sbst_obj = subset_state.roi
if isinstance(sbst_obj, (CircularROI, CircularAnnulusROI, EllipticalROI)):
cen = sbst_obj.get_center()
elif isinstance(sbst_obj, RectangularROI):
cen = sbst_obj.center()
else: # pragma: no cover
raise NotImplementedError(
f'Getting center of {sbst_obj.__class__} is not supported')

elif isinstance(subset_state, RangeSubsetState):
cen = (subset_state.hi - subset_state.lo) * 0.5 + subset_state.lo

elif isinstance(subset_state, CompositeSubsetState):
cen = None

else: # pragma: no cover
raise NotImplementedError(
f'Getting center of {subset_state.__class__} is not supported')

return cen
return subset_state.center()

def set_center(self, new_cen, update=False):
"""Set the desired center for the selected Subset, if applicable.
Expand Down Expand Up @@ -464,7 +438,7 @@ def set_center(self, new_cen, update=False):
raise NotImplementedError(f'Recentering of {sbst_obj.__class__} is not supported')

elif isinstance(subset_state, RangeSubsetState):
dx = new_cen - ((subset_state.hi - subset_state.lo) * 0.5 + subset_state.lo)
dx = new_cen - subset_state.center()
self._set_value_in_subset_definition(0, "Lower bound", "value", subset_state.lo + dx)
self._set_value_in_subset_definition(0, "Upper bound", "value", subset_state.hi + dx)

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
"bqplot>=0.12.37",
"bqplot-image-gl>=1.4.11",
"glue-core>=1.11",
"glue-jupyter>=0.16.3",
"glue-jupyter>=0.17",
"echo>=0.5.0",
"ipykernel>=6.19.4",
"ipyvue>=1.6",
Expand All @@ -26,7 +26,7 @@ dependencies = [
"specutils>=1.9",
"specreduce>=1.3.0,<1.4.0",
"photutils>=1.4",
"glue-astronomy>=0.9",
"glue-astronomy>=0.10",
"asteval>=0.9.23",
"idna",
"vispy>=0.6.5",
Expand Down

0 comments on commit d068130

Please sign in to comment.