From aefc6b60f16a35d65f38405923c0c0c9d6121009 Mon Sep 17 00:00:00 2001 From: Derek Homeier Date: Thu, 11 May 2023 16:00:07 +0200 Subject: [PATCH] No longer use deprecated `CircularROI.get_center` --- glue_astronomy/translators/regions.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/glue_astronomy/translators/regions.py b/glue_astronomy/translators/regions.py index ffffa28..31c74f1 100644 --- a/glue_astronomy/translators/regions.py +++ b/glue_astronomy/translators/regions.py @@ -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): """ @@ -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)