Skip to content

Commit

Permalink
Fix tests with latest developer version of Astropy
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Nov 8, 2016
1 parent 4894696 commit 2f06fc5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
6 changes: 5 additions & 1 deletion regions/shapes/tests/test_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from astropy.wcs import WCS
from ...core import PixCoord
from ..circle import CirclePixelRegion, CircleSkyRegion
from .utils import ASTROPY_LT_13

try:
import matplotlib
Expand Down Expand Up @@ -39,7 +40,10 @@ def test_circle_sky():
center = SkyCoord(3 * u.deg, 4 * u.deg)
reg = CircleSkyRegion(center, 2 * u.arcsec)

assert str(reg) == 'CircleSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n (3.0, 4.0)>\nradius: 2.0 arcsec'
if ASTROPY_LT_13:
assert str(reg) == 'CircleSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n (3.0, 4.0)>\nradius: 2.0 arcsec'
else:
assert str(reg) == 'CircleSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n ( 3., 4.)>\nradius: 2.0 arcsec'


def test_transformation():
Expand Down
10 changes: 8 additions & 2 deletions regions/shapes/tests/test_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from astropy.coordinates import SkyCoord
from ...core import PixCoord
from ..ellipse import EllipsePixelRegion, EllipseSkyRegion
from .utils import ASTROPY_LT_13


def test_ellipse_pixel():
Expand All @@ -17,6 +18,11 @@ def test_ellipse_sky():
center = SkyCoord(3, 4, unit='deg')
reg = EllipseSkyRegion(center, 3 * u.deg, 4 * u.deg, 5 * u.deg)

expected = ('EllipseSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n'
' (3.0, 4.0)>\nminor: 3.0 deg\nmajor: 4.0 deg\nangle: 5.0 deg')
if ASTROPY_LT_13:
expected = ('EllipseSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n'
' (3.0, 4.0)>\nminor: 3.0 deg\nmajor: 4.0 deg\nangle: 5.0 deg')
else:
expected = ('EllipseSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n'
' ( 3., 4.)>\nminor: 3.0 deg\nmajor: 4.0 deg\nangle: 5.0 deg')

assert str(reg) == expected
6 changes: 5 additions & 1 deletion regions/shapes/tests/test_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from astropy.coordinates import SkyCoord
from ...core import PixCoord
from ..point import PointPixelRegion, PointSkyRegion
from .utils import ASTROPY_LT_13


def test_ellipse_pixel():
Expand All @@ -16,4 +17,7 @@ def test_ellipse_sky():
center = SkyCoord(3, 4, unit='deg')
reg = PointSkyRegion(center)

assert str(reg) == 'PointSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n (3.0, 4.0)>'
if ASTROPY_LT_13:
assert str(reg) == 'PointSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n (3.0, 4.0)>'
else:
assert str(reg) == 'PointSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n ( 3., 4.)>'
9 changes: 7 additions & 2 deletions regions/shapes/tests/test_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from astropy.coordinates import SkyCoord
from ...core import PixCoord
from ..polygon import PolygonPixelRegion, PolygonSkyRegion
from .utils import ASTROPY_LT_13


@pytest.fixture
Expand All @@ -26,8 +27,12 @@ def test_polygon_pixel(pix_poly):


def test_polygon_sky(sky_poly):
expected = ('PolygonSkyRegion\nvertices: <SkyCoord (ICRS): (ra, dec) in deg\n'
' [(3.0, 3.0), (4.0, 4.0), (3.0, 4.0)]>')
if ASTROPY_LT_13:
expected = ('PolygonSkyRegion\nvertices: <SkyCoord (ICRS): (ra, dec) in deg\n'
' [(3.0, 3.0), (4.0, 4.0), (3.0, 4.0)]>')
else:
expected = ('PolygonSkyRegion\nvertices: <SkyCoord (ICRS): (ra, dec) in deg\n'
' [( 3., 3.), ( 4., 4.), ( 3., 4.)]>')
assert str(sky_poly) == expected


Expand Down
10 changes: 7 additions & 3 deletions regions/shapes/tests/test_rectangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from astropy.coordinates import SkyCoord
from ...core import PixCoord
from ..rectangle import RectanglePixelRegion, RectangleSkyRegion
from .utils import ASTROPY_LT_13


def test_ellipse_pixel():
Expand All @@ -16,7 +17,10 @@ def test_ellipse_pixel():
def test_ellipse_sky():
center = SkyCoord(3, 4, unit='deg')
reg = RectangleSkyRegion(center, 3 * u.deg, 4 * u.deg, 5 * u.deg)

expected = ('RectangleSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n'
' (3.0, 4.0)>\nheight: 3.0 deg\nwidth: 4.0 deg\nangle: 5.0 deg')
if ASTROPY_LT_13:
expected = ('RectangleSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n'
' (3.0, 4.0)>\nheight: 3.0 deg\nwidth: 4.0 deg\nangle: 5.0 deg')
else:
expected = ('RectangleSkyRegion\ncenter: <SkyCoord (ICRS): (ra, dec) in deg\n'
' ( 3., 4.)>\nheight: 3.0 deg\nwidth: 4.0 deg\nangle: 5.0 deg')
assert str(reg) == expected
5 changes: 5 additions & 0 deletions regions/shapes/tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from distutils.version import LooseVersion

import astropy

ASTROPY_LT_13 = LooseVersion(astropy.__version__) < LooseVersion('1.3')

0 comments on commit 2f06fc5

Please sign in to comment.