Skip to content

Commit

Permalink
Merge pull request #2589 from pllim/fix-ann-reg-test
Browse files Browse the repository at this point in the history
TST: Fix ds9_annulus_01.reg test case
  • Loading branch information
pllim authored Dec 6, 2023
2 parents 31fc369 + d6d8a64 commit a86e698
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jdaviz/configs/imviz/tests/data/ds9_annulus_01.reg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Region file format: DS9 version 4.1
global color=green dashlist=8 3 width=1 font="helvetica 10 normal roman" select=1 highlite=1 dash=0 fixed=0 edit=1 move=1 delete=1 include=1 source=1
icrs
annulus(197.8929,-1.36599,1.9820003",3.9640007",5.946001") # color=magenta font="helvetica 10 bold roman" text={Annulus}
annulus(337.51894337,-20.83208305,0.5",1.0",3") # color=magenta font="helvetica 10 bold roman" text={Annulus}
8 changes: 7 additions & 1 deletion jdaviz/configs/imviz/tests/test_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from astropy import units as u
from astropy.coordinates import SkyCoord, Angle
from astropy.utils.data import get_pkg_data_filename
from numpy.testing import assert_allclose
from photutils.aperture import CircularAperture, SkyCircularAperture
from regions import (PixCoord, CircleSkyRegion, RectanglePixelRegion, CirclePixelRegion,
EllipsePixelRegion, PointSkyRegion, PolygonPixelRegion,
Expand Down Expand Up @@ -154,11 +155,16 @@ def test_regions_annulus_from_load_data(self):
self.imviz.load_data(regfile)
assert len(self.imviz.app.data_collection) == 2 # Make sure not loaded as data

# Test data is set up such that 1 pixel is 1 arcsec.
subset_radii = {"Subset 1": [0.5, 1], "Subset 2": [1, 3]}

subsets = self.imviz.get_interactive_regions()
subset_names = list(subsets.keys())
subset_names = sorted(subsets.keys())
assert subset_names == ['Subset 1', 'Subset 2']
for n in subset_names:
assert isinstance(subsets[n], CircleAnnulusPixelRegion)
assert_allclose(subsets[n].center.xy, 4.5, rtol=5e-6)
assert_allclose([subsets[n].inner_radius, subsets[n].outer_radius], subset_radii[n])

def test_photutils_pixel(self):
my_aper = CircularAperture((5, 5), r=2)
Expand Down

0 comments on commit a86e698

Please sign in to comment.