From 9ecbc6ef5868891df7f5b986bfdc656162707f4b Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Sun, 24 Nov 2013 22:23:49 +0100 Subject: [PATCH 1/2] Use Astropy by default if possible --- skimage/io/_plugins/fits_plugin.py | 11 +++++++---- skimage/io/tests/test_fits.py | 10 +++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/skimage/io/_plugins/fits_plugin.py b/skimage/io/_plugins/fits_plugin.py index 52785814..cf714ea6 100644 --- a/skimage/io/_plugins/fits_plugin.py +++ b/skimage/io/_plugins/fits_plugin.py @@ -3,11 +3,14 @@ __all__ = ['imread', 'imread_collection'] import skimage.io as io try: - import pyfits + from astropy.io import fits as pyfits except ImportError: - raise ImportError("PyFITS could not be found. Please refer to\n" - "http://www.stsci.edu/resources/software_hardware/pyfits\n" - "for further instructions.") + try: + import pyfits + except ImportError: + raise ImportError("PyFITS could not be found. Please refer to\n" + "http://www.stsci.edu/resources/software_hardware/pyfits\n" + "for further instructions.") def imread(fname, dtype=None): diff --git a/skimage/io/tests/test_fits.py b/skimage/io/tests/test_fits.py index d432b611..4fa1b467 100644 --- a/skimage/io/tests/test_fits.py +++ b/skimage/io/tests/test_fits.py @@ -9,10 +9,14 @@ from skimage import data_dir pyfits_available = True try: - import pyfits + from astropy.io import fits as pyfits except ImportError: - pyfits_available = False -else: + try: + import pyfits + except ImportError: + pyfits_available = False + +if pyfits_available: import skimage.io._plugins.fits_plugin as fplug From 32d6fc322485fe62c7eabc3006db590ef3be7ea8 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Sun, 24 Nov 2013 22:28:54 +0100 Subject: [PATCH 2/2] Added entry for Astropy in DEPENDS.txt --- DEPENDS.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DEPENDS.txt b/DEPENDS.txt index a2c5bb5c..c4cc8679 100644 --- a/DEPENDS.txt +++ b/DEPENDS.txt @@ -50,6 +50,8 @@ functionality is only available with the following installed: (or <`PIL http://www.pythonware.com/products/pil/>`__) The ``Pillow`` library (or equivalently ``PIL``) is used for Input/Output. +* `Astropy `__ is required to use the FITS io plug-in. + Testing requirements -------------------- * `Nose `__