From d323b761917b1c713fbb367a86dac84bfa7e0af6 Mon Sep 17 00:00:00 2001 From: mdroe Date: Fri, 13 Jun 2014 18:24:20 +0000 Subject: Add regression tests based on real data that had trouble in the past. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci.sphere/trunk@32539 fe389314-cf27-0410-b35b-8c050e845b92 Former-commit-id: f371222ebbc956ebbef4af6fba283e60e90e5a5b --- stsci/sphere/test/test_intersection.py | 46 ++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'stsci/sphere/test/test_intersection.py') diff --git a/stsci/sphere/test/test_intersection.py b/stsci/sphere/test/test_intersection.py index 8127e95..8cf10b2 100644 --- a/stsci/sphere/test/test_intersection.py +++ b/stsci/sphere/test/test_intersection.py @@ -140,28 +140,6 @@ def test4(): X = Apoly.intersection(Bpoly) -# def test5(): -# from astropy.io import fits -# from astropy import wcs as pywcs - -# A = fits.open(os.path.join(ROOT_DIR, '2chipA.fits.gz')) -# B = fits.open(os.path.join(ROOT_DIR, '2chipB.fits.gz')) - -# wcs = pywcs.WCS(A[1].header, fobj=A) -# chipA1 = polygon.SphericalPolygon.from_wcs(wcs) -# wcs = pywcs.WCS(A[4].header, fobj=A) -# chipA2 = polygon.SphericalPolygon.from_wcs(wcs) -# wcs = pywcs.WCS(B[1].header, fobj=B) -# chipB1 = polygon.SphericalPolygon.from_wcs(wcs) -# wcs = pywcs.WCS(B[4].header, fobj=B) -# chipB2 = polygon.SphericalPolygon.from_wcs(wcs) - -# Apoly = chipA1.union(chipA2) -# Bpoly = chipB1.union(chipB2) - -# Apoly.overlap(chipB1) - - @intersection_test(0, 90) def test6(): from astropy.io import fits @@ -188,6 +166,30 @@ def test_intersection_empty(): assert_array_almost_equal(p2._points, []) +def test_difficult_intersections(): + # Tests a number of intersections of real data that have been + # problematic in previous revisions of sphere + + def test_intersection(polys): + A, B = polys + A.intersection(B) + + fname = resolve_imagename(ROOT_DIR, "difficult_intersections.txt") + with open(fname, 'rb') as fd: + lines = fd.readlines() + + def to_array(line): + x = np.frombuffer(line.strip().decode('hex'), dtype='