Skip to content

Commit

Permalink
Consolidate this with center() and move_to()
Browse files Browse the repository at this point in the history
Commit suggestion

Co-authored-by: P. L. Lim <[email protected]>

Codestyle
  • Loading branch information
rosteen committed Oct 23, 2023
1 parent 3353575 commit 9e955a8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1939,14 +1939,12 @@ def _reparent_subsets(self, old_parent, new_parent=None):
roi = subset_group.subset_state.roi
if type(roi) in (CircularROI, CircularAnnulusROI,
EllipticalROI, TrueCircularROI):
old_xc = roi.xc
old_yc = roi.yc
old_xc, old_yc = subset_group.subset_state.center()
# Convert center
x, y = pixel_to_pixel(old_parent.coords, new_parent.coords,
roi.xc, roi.yc)
# Can't use set_center here because CircularAnnulusROI doesn't have it
roi.xc = x
roi.yc = y
subset_group.subset_state.move_to(x, y)

for att in ("radius", "inner_radius", "outer_radius",
"radius_x", "radius_y"):
Expand Down Expand Up @@ -1976,8 +1974,8 @@ def _reparent_subsets(self, old_parent, new_parent=None):
cur_unit = old_parent.coords.spectral_axis.unit
new_unit = new_parent.coords.spectral_axis.unit
if cur_unit is not new_unit:
range_state.lo = (range_state.lo*cur_unit).to(new_unit).value
range_state.hi = (range_state.hi*cur_unit).to(new_unit).value
range_state.lo, range_state.hi = cur_unit.to(new_unit, [range_state.lo,
range_state.hi])

# Force subset plugin to update bounds and such
for subset in subset_group.subsets:
Expand Down

0 comments on commit 9e955a8

Please sign in to comment.