Skip to content

Commit

Permalink
Merge pull request #91 from dhomeier/unget-center
Browse files Browse the repository at this point in the history
Use `CircularROI.center` to avoid deprecation warnings with glue_core >= 1.10
  • Loading branch information
dhomeier authored May 11, 2023
2 parents 336e2cc + aefc6b6 commit dab988a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion glue_astronomy/translators/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
from glue.core.roi import (RectangularROI, PolygonalROI, CircularROI, PointROI,
RangeROI, AbstractMplRoi, EllipticalROI)
from glue.viewers.image.pixel_selection_subset_state import PixelSubsetState
from glue import __version__ as glue_version

from astropy import units as u
from packaging.version import Version
from regions import (RectanglePixelRegion, PolygonPixelRegion, CirclePixelRegion,
PointPixelRegion, PixCoord, EllipsePixelRegion,
AnnulusPixelRegion, CircleAnnulusPixelRegion)

__all__ = ["range_to_rect", "AstropyRegionsHandler"]

GLUE_LT_1_10 = Version(glue_version) < Version('1.10')


def range_to_rect(data, ori, low, high):
"""
Expand Down Expand Up @@ -117,7 +121,8 @@ def to_object(self, subset):
elif isinstance(roi, PolygonalROI):
return PolygonPixelRegion(PixCoord(roi.vx, roi.vy))
elif isinstance(roi, CircularROI):
return CirclePixelRegion(PixCoord(*roi.get_center()), roi.get_radius())
xcen, ycen = roi.get_center() if GLUE_LT_1_10 else roi.center()
return CirclePixelRegion(PixCoord(xcen, ycen), roi.get_radius())
elif isinstance(roi, EllipticalROI):
return EllipsePixelRegion(
PixCoord(roi.xc, roi.yc), roi.radius_x * 2, roi.radius_y * 2, angle=angle)
Expand Down

0 comments on commit dab988a

Please sign in to comment.