def test_circle_annulus(self): r = regions.CircleAnnulusPixelRegion(center=regions.PixCoord(x=42, y=43), inner_radius=4.2, outer_radius=5.2) o = r2g(r) assert isinstance(o, dc.Annulus) assert np.all(np.isclose((o.x, o.y, o.radius, o.radius + o.width), (r.center.x, r.center.y, r.inner_radius, r.outer_radius)))
def test_line(self): r = regions.LinePixelRegion(start=regions.PixCoord(x=42, y=43), end=regions.PixCoord(x=42, y=43)) o = r2g(r) assert isinstance(o, dc.Line) assert np.all(np.isclose((o.x1, o.y1, o.x2, o.y2), (r.start.x, r.start.y, r.end.x, r.end.y)))
def test_ellipse(self): r = regions.EllipsePixelRegion(center=regions.PixCoord(x=42, y=43), height=4.2, width=4.2, angle=5 * u.deg) o = r2g(r) assert isinstance(o, dc.Ellipse) assert np.all(np.isclose((o.x, o.y, o.xradius, o.yradius, o.rot_deg), (r.center.x, r.center.y, r.width / 2., r.height / 2., r.angle.to(u.deg).value)))
def test_text(self): r = regions.TextPixelRegion(center=regions.PixCoord(x=42, y=43), text='Foo', visual=regions.RegionVisual(textangle='45')) o = r2g(r) assert isinstance(o, dc.Text) and o.text == 'Foo' assert np.all(np.isclose((o.x, o.y, o.rot_deg), (r.center.x, r.center.y, float(r.visual['textangle']))))
def test_ellipse_annulus(self): r = regions.EllipseAnnulusPixelRegion(center=regions.PixCoord(x=42, y=43), inner_width=4.2, outer_width=5.2, inner_height=7.2, outer_height=8.2, angle=5 * u.deg) o = r2g(r) assert isinstance(o, dc.Annulus2R) and o.atype == 'ellipse' assert np.all(np.isclose((o.x, o.y, o.xradius, o.yradius, o.xradius + o.xwidth, o.yradius + o.ywidth, o.rot_deg), (r.center.x, r.center.y, r.inner_width / 2., r.inner_height / 2., r.outer_width / 2., r.outer_height / 2., r.angle.to(u.deg).value)))
def test_polygon(self): r = regions.PolygonPixelRegion(vertices=regions.PixCoord(x=[1, 2, 2], y=[1, 1, 2])) o = r2g(r) assert isinstance(o, dc.Polygon) assert np.all(np.isclose(o.points, np.array(r.vertices.xy).T))
def test_circle(self): r = regions.CirclePixelRegion(center=regions.PixCoord(x=42, y=43), radius=4.2) o = r2g(r) assert isinstance(o, dc.Circle) assert np.all(np.isclose((o.x, o.y, o.radius), (r.center.x, r.center.y, r.radius)))
def test_point3(self): r = regions.PointPixelRegion(center=regions.PixCoord(x=42, y=43), visual=regions.RegionVisual(symbol='*')) o = r2g(r) assert isinstance(o, dc.Point) and o.style == 'square'
def test_point1(self): r = regions.PointPixelRegion(center=regions.PixCoord(x=42, y=43), visual=regions.RegionVisual(symbol='x')) o = r2g(r) assert isinstance(o, dc.Point) and o.style == 'cross' assert np.all(np.isclose((o.x, o.y), (r.center.x, r.center.y)))