mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-01 17:28:23 +08:00
Fix handling of ImageCollection indexing and add test
This commit is contained in:
@@ -254,13 +254,16 @@ class ImageCollection(object):
|
||||
|
||||
if ((self.conserve_memory and n != self._cached) or
|
||||
(self.data[idx] is None)):
|
||||
kwargs = self.load_func_kwargs
|
||||
if self._frame_index:
|
||||
fname, img_num = self._frame_index[n]
|
||||
self.data[idx] = self.load_func(fname, img_num=img_num,
|
||||
**self.load_func_kwargs)
|
||||
if img_num > 0:
|
||||
self.data[idx] = self.load_func(fname, img_num=img_num,
|
||||
**kwargs)
|
||||
else:
|
||||
self.data[idx] = self.load_func(fname, **kwargs)
|
||||
else:
|
||||
self.data[idx] = self.load_func(self.files[n],
|
||||
**self.load_func_kwargs)
|
||||
self.data[idx] = self.load_func(self.files[n], **kwargs)
|
||||
self._cached = n
|
||||
|
||||
return self.data[idx]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import skimage as si
|
||||
import skimage.io as sio
|
||||
from skimage import data_dir
|
||||
import numpy as np
|
||||
|
||||
from numpy.testing import *
|
||||
@@ -12,6 +13,7 @@ try:
|
||||
FI_available = True
|
||||
sio.use_plugin('freeimage')
|
||||
except RuntimeError:
|
||||
raise
|
||||
FI_available = False
|
||||
|
||||
np.random.seed(0)
|
||||
@@ -112,5 +114,13 @@ def test_metadata():
|
||||
assert meta[1][('EXIF_MAIN', 'Software')].startswith('I')
|
||||
|
||||
|
||||
@skipif(not FI_available)
|
||||
def test_collection():
|
||||
pattern = [os.path.join(data_dir, pic)
|
||||
for pic in ['camera.png', 'color.png']]
|
||||
images = sio.ImageCollection(pattern)
|
||||
assert len(images) == 2
|
||||
assert len(images[:]) == 2
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user