summaryrefslogtreecommitdiff
path: root/lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/test')
-rw-r--r--lib/test/benchmarks.py12
-rw-r--r--lib/test/test.py4
-rw-r--r--lib/test/test_intersection.py7
-rw-r--r--lib/test/test_shared.py12
-rw-r--r--lib/test/test_union.py3
5 files changed, 27 insertions, 11 deletions
diff --git a/lib/test/benchmarks.py b/lib/test/benchmarks.py
index 9711d7b..91ef8db 100644
--- a/lib/test/benchmarks.py
+++ b/lib/test/benchmarks.py
@@ -5,14 +5,14 @@ import time
import numpy as np
from sphere import *
from test_util import *
+from test_shared import resolve_imagename
def point_in_poly_lots():
- poly1 = SphericalPolygon.from_wcs(
- os.path.join(ROOT_DIR, '1904-66_TAN.fits'), 64, crval=[0, 87])
- poly2 = SphericalPolygon.from_wcs(
- os.path.join(ROOT_DIR, '1904-66_TAN.fits'), 64, crval=[20, 89])
- poly3 = SphericalPolygon.from_wcs(
- os.path.join(ROOT_DIR, '1904-66_TAN.fits'), 64, crval=[180, 89])
+ image_name = resolve_imagename(ROOT_DIR,'1904-66_TAN.fits')
+
+ poly1 = SphericalPolygon.from_wcs(image_name, 64, crval=[0, 87])
+ poly2 = SphericalPolygon.from_wcs(image_name, 64, crval=[20, 89])
+ poly3 = SphericalPolygon.from_wcs(image_name, 64, crval=[180, 89])
points = get_point_set(density=25)
diff --git a/lib/test/test.py b/lib/test/test.py
index c6c1fcd..bceac50 100644
--- a/lib/test/test.py
+++ b/lib/test/test.py
@@ -10,7 +10,7 @@ from sphere import polygon
from sphere import vector
from .test_util import *
-
+from test_shared import resolve_imagename
graph.DEBUG = True
@@ -155,7 +155,7 @@ def test_point_in_poly():
def test_point_in_poly_lots():
import pyfits
- fits = pyfits.open(os.path.join(ROOT_DIR, '1904-66_TAN.fits'))
+ fits = pyfits.open(resolve_imagename(ROOT_DIR, '1904-66_TAN.fits'))
header = fits[0].header
poly1 = polygon.SphericalPolygon.from_wcs(
diff --git a/lib/test/test_intersection.py b/lib/test/test_intersection.py
index 81512d1..adb79f0 100644
--- a/lib/test/test_intersection.py
+++ b/lib/test/test_intersection.py
@@ -14,6 +14,7 @@ from numpy.testing import assert_array_almost_equal
# LOCAL
from sphere import polygon
+from test_shared import resolve_imagename
GRAPH_MODE = False
ROOT_DIR = os.path.join(os.path.dirname(__file__), 'data')
@@ -77,7 +78,9 @@ class intersection_test:
@intersection_test(0, 90)
def test1():
import pyfits
- fits = pyfits.open(os.path.join(ROOT_DIR, '1904-66_TAN.fits'))
+ import os
+
+ fits = pyfits.open(resolve_imagename(ROOT_DIR,'1904-66_TAN.fits'))
header = fits[0].header
poly1 = polygon.SphericalPolygon.from_wcs(
@@ -99,7 +102,7 @@ def test2():
@intersection_test(0, 90)
def test3():
import pyfits
- fits = pyfits.open(os.path.join(ROOT_DIR, '1904-66_TAN.fits'))
+ fits = pyfits.open(resolve_imagename(ROOT_DIR, '1904-66_TAN.fits'))
header = fits[0].header
poly1 = polygon.SphericalPolygon.from_wcs(
diff --git a/lib/test/test_shared.py b/lib/test/test_shared.py
new file mode 100644
index 0000000..fa7d249
--- /dev/null
+++ b/lib/test/test_shared.py
@@ -0,0 +1,12 @@
+import os
+
+def resolve_imagename(ROOT_DIR, base_name):
+ """Resolve image name for tests."""
+
+ image_name = os.path.join(ROOT_DIR, base_name)
+
+ # Is it zipped?
+ if not os.path.isfile(image_name):
+ image_name.replace('.fits', '.fits.gz')
+
+ return image_name
diff --git a/lib/test/test_union.py b/lib/test/test_union.py
index 66abda8..c963b76 100644
--- a/lib/test/test_union.py
+++ b/lib/test/test_union.py
@@ -14,6 +14,7 @@ from numpy.testing import assert_array_almost_equal
# LOCAL
from sphere import polygon
+from test_shared import resolve_imagename
GRAPH_MODE = False
ROOT_DIR = os.path.join(os.path.dirname(__file__), 'data')
@@ -77,7 +78,7 @@ class union_test:
@union_test(0, 90)
def test1():
import pyfits
- fits = pyfits.open(os.path.join(ROOT_DIR, '1904-66_TAN.fits'))
+ fits = pyfits.open(resolve_imagename(ROOT_DIR, '1904-66_TAN.fits'))
header = fits[0].header
poly1 = polygon.SphericalPolygon.from_wcs(