From cb44e508f33c4811fe440d801b4ca71e2aef9d4d Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 28 May 2012 19:46:39 -0400 Subject: [PATCH 1/2] Allow for type of hdu.size changing in PyFITS 3.1 --- skimage/io/_plugins/fits_plugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/skimage/io/_plugins/fits_plugin.py b/skimage/io/_plugins/fits_plugin.py index 0f7b741f..0643285d 100644 --- a/skimage/io/_plugins/fits_plugin.py +++ b/skimage/io/_plugins/fits_plugin.py @@ -95,8 +95,12 @@ def imread_collection(load_pattern, conserve_memory=True): isinstance(hdu, pyfits.PrimaryHDU): # Ignore (primary) header units with no data (use '.size' # rather than '.data' to avoid actually loading the image): - if hdu.size() > 0: - ext_list.append((filename, n)) + try: + if hdu.size() > 0: + ext_list.append((filename, n)) + except TypeError: # (size changed to int in PyFITS 3.1) + if hdu.size > 0: + ext_list.append((filename, n)) hdulist.close() return io.ImageCollection(ext_list, load_func=FITSFactory, From 3c83eb896636ad1115ad337d22fb5090d0b4ddc7 Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 29 May 2012 11:36:42 -0400 Subject: [PATCH 2/2] Readability improvement suggested by tonysyu --- skimage/io/_plugins/fits_plugin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skimage/io/_plugins/fits_plugin.py b/skimage/io/_plugins/fits_plugin.py index 0643285d..b6627032 100644 --- a/skimage/io/_plugins/fits_plugin.py +++ b/skimage/io/_plugins/fits_plugin.py @@ -96,11 +96,11 @@ def imread_collection(load_pattern, conserve_memory=True): # Ignore (primary) header units with no data (use '.size' # rather than '.data' to avoid actually loading the image): try: - if hdu.size() > 0: - ext_list.append((filename, n)) + data_size = hdu.size() except TypeError: # (size changed to int in PyFITS 3.1) - if hdu.size > 0: - ext_list.append((filename, n)) + data_size = hdu.size + if data_size > 0: + ext_list.append((filename, n)) hdulist.close() return io.ImageCollection(ext_list, load_func=FITSFactory,