8000 Update test for custom load_func · scikit-image/scikit-image@03d2936 · GitHub
[go: up one dir, main page]

Skip to content

Commit 03d2936

Browse files
committed
Update test for custom load_func
1 parent d3a968e commit 03d2936

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

skimage/io/tests/test_collection.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22

33
import numpy as np
4+
import imageio
45
from skimage import data_dir
56
from skimage.io.collection import ImageCollection, MultiImage, alphanumeric_key
67
from skimage.io import reset_plugins
@@ -94,30 +95,19 @@ def set_files(f):
9495
with testing.raises(AttributeError):
9596
set_files('newfiles')
9697

97-
def test_custom_pattern(self):
98-
load_pattern = os.path.join(data_dir, 'b??ck.png')
99-
files = [os.path.join(data_dir, pic)
100-
for pic in ['block.png', 'brick.png']]
98+
def test_custom_load_func_w_kwarg(self):
99+
load_pattern = os.path.join(data_dir, 'no_time_for_that_tiny.gif')
101100

102-
def load_fn(x):
103-
return x
104-
105-
ic = ImageCollection(load_pattern, load_func=load_fn)
106-
assert_equal(ic[0], files[0])
107-
assert_equal(ic[1], files[1])
108-
109-
def test_custom_pattern_not_pil(self):
110-
load_pattern = os.path.join(data_dir, 'chessboard_*_U8.npz')
111-
files = [os.path.join(data_dir, pic)
112-
for pic in ['chessboard_GRAY_U8.npz',
113-
'chessboard_RGB_U8.npz']]
114-
115-
def load_fn(x):
116-
return x
101+
def load_fn(f, step):
102+
vid = imageio.get_reader(f)
103+
seq = [v for v in vid.iter_data()]
104+
return seq[::step]
117105

118-
ic = ImageCollection(load_pattern, load_func=load_fn)
119-
assert_equal(ic[0], files[0])
120-
assert_equal(ic[1], files[1])
106+
ic = ImageCollection(load_pattern, load_func=load_fn, step=3)
107+
# Each file should map to one image (array).
108+
assert len(ic) == 1
109+
# GIF file has 24 frames, so 24 / 3 equals 8.
110+
assert len(ic[0]) == 8
121111

122112
def test_custom_load_func(self):
123113

0 commit comments

Comments
 (0)
0