JT: more minor comments from Stefan

This commit is contained in:
James Turner
2010-07-03 17:44:35 -04:00
parent 57ed210a6b
commit 09268cc062
2 changed files with 42 additions and 37 deletions
+6 -6
View File
@@ -111,12 +111,12 @@ def FITSFactory(image_ext):
Parameters
----------
image_ext : tuple
FITS extension to load, in the format ``(filename, ext_num)``.
The ``(extname, extver)`` format is unsupported, since this
function is not called directly by the user and
``imread_collection()`` does the work of figuring out which
extensions need loading.
image_ext : tuple
FITS extension to load, in the format ``(filename, ext_num)``.
The FITS ``(extname, extver)`` format is unsupported, since this
function is not called directly by the user and
``imread_collection()`` does the work of figuring out which
extensions need loading.
"""
+36 -31
View File
@@ -1,16 +1,17 @@
import os.path
import numpy as np
from numpy.testing import run_module_suite
from numpy.testing.decorators import skipif
import scikits.image.io as io
from scikits.image import data_dir
import scikits.image.io._plugins.fits_plugin as fplug
import_success = True
pyfits_available = True
try:
import pyfits
except ImportError:
import_success = False
pyfits_available = False
def test_fits_plugin_import():
@@ -20,43 +21,43 @@ def test_fits_plugin_import():
try:
io.use_plugin('fits')
except ImportError:
assert import_success == False
assert pyfits_available == False
else:
assert import_success == True
assert pyfits_available == True
@skipif(not pyfits_available)
def test_imread_MEF():
if import_success:
io.use_plugin('fits')
testfile = os.path.join(data_dir, 'multi.fits')
img = io.imread(testfile)
assert np.all(img==pyfits.getdata(testfile, 1))
io.use_plugin('fits')
testfile = os.path.join(data_dir, 'multi.fits')
img = io.imread(testfile)
assert np.all(img==pyfits.getdata(testfile, 1))
@skipif(not pyfits_available)
def test_imread_simple():
if import_success:
io.use_plugin('fits')
testfile = os.path.join(data_dir, 'simple.fits')
img = io.imread(testfile)
assert np.all(img==pyfits.getdata(testfile, 0))
io.use_plugin('fits')
testfile = os.path.join(data_dir, 'simple.fits')
img = io.imread(testfile)
assert np.all(img==pyfits.getdata(testfile, 0))
@skipif(not pyfits_available)
def test_imread_collection_single_MEF():
if import_success:
io.use_plugin('fits')
testfile = os.path.join(data_dir, 'multi.fits')
ic1 = io.imread_collection(testfile)
ic2 = io.ImageCollection([(testfile, 1), (testfile, 2), (testfile, 3)],
load_func=fplug.FITSFactory)
assert _same_ImageCollection(ic1, ic2)
io.use_plugin('fits')
testfile = os.path.join(data_dir, 'multi.fits')
ic1 = io.imread_collection(testfile)
ic2 = io.ImageCollection([(testfile, 1), (testfile, 2), (testfile, 3)],
load_func=fplug.FITSFactory)
assert _same_ImageCollection(ic1, ic2)
@skipif(not pyfits_available)
def test_imread_collection_MEF_and_simple():
if import_success:
io.use_plugin('fits')
testfile1 = os.path.join(data_dir, 'multi.fits')
testfile2 = os.path.join(data_dir, 'simple.fits')
ic1 = io.imread_collection([testfile1, testfile2])
ic2 = io.ImageCollection([(testfile1, 1), (testfile1, 2),
(testfile1, 3), (testfile2, 0)],
load_func=fplug.FITSFactory)
assert _same_ImageCollection(ic1, ic2)
io.use_plugin('fits')
testfile1 = os.path.join(data_dir, 'multi.fits')
testfile2 = os.path.join(data_dir, 'simple.fits')
ic1 = io.imread_collection([testfile1, testfile2])
ic2 = io.ImageCollection([(testfile1, 1), (testfile1, 2),
(testfile1, 3), (testfile2, 0)],
load_func=fplug.FITSFactory)
assert _same_ImageCollection(ic1, ic2)
def _same_ImageCollection(collection1, collection2):
"""Ancillary function to compare two ImageCollection objects, checking
@@ -69,3 +70,7 @@ def _same_ImageCollection(collection1, collection2):
return False
return True
if __name__ == '__main__':
run_module_suite()