Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new API from glue-core #2204

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,9 @@ def _get_roi_subset_definition(self, subset_state):
_around_decimals = 6
roi = subset_state.roi
roi_as_region = None

if isinstance(roi, CircularROI):
x, y = roi.get_center()
x, y = roi.center()
r = roi.radius
roi_as_region = CirclePixelRegion(PixCoord(x, y), r)

Expand Down
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 @@ -143,7 +143,7 @@ def _unpack_get_subsets_for_ui(self):
glue_state = spec["glue_state"]
if isinstance(subset_state, RoiSubsetState):
if isinstance(subset_state.roi, CircularROI):
x, y = subset_state.roi.get_center()
x, y = subset_state.roi.center()
r = subset_state.roi.radius
subset_definition = [{"name": "X Center", "att": "xc", "value": x, "orig": x},
{"name": "Y Center", "att": "yc", "value": y, "orig": y},
Expand Down Expand Up @@ -267,39 +267,13 @@ def get_center(self):
depending on the Subset type, if applicable.
If Subset is not editable, this returns `None`.

Raises
------
NotImplementedError
Subset type is not supported.

"""
# Composite region cannot be edited.
if not self.is_editable: # 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, 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 @@ -346,7 +320,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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies = [
"traitlets>=5.0.5",
"bqplot>=0.12.37",
"bqplot-image-gl>=1.4.11",
"glue-core>=1.6.0,!=1.9.0,!=1.10",
"glue-core>=1.10.1",
"glue-jupyter>=0.15.0",
"echo>=0.5.0",
"ipykernel>=6.19.4",
Expand Down