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 CircularROI.center to avoid deprecation warnings with glue_core >= 1.10 #91

Merged
merged 1 commit into from
May 11, 2023
Merged
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
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