mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-28 22:04:10 +08:00
78a0eb6b98
Implement Appveyor builds initial test Updated appveyor.yml New nosetest call With conda update conda with pillow without pillow TST: Change case sensitivive JPG extension Revert "TST: Change case sensitivive JPG extension" This reverts commit 2deed7cc63736f7c6f0387bd37df4c6643c32847. Trying with Python 2.7 Trying with version env Trying again with variables Testing on all Python versions don't allow failures Allow failure Do not actually use tests Ignore failing tests Removed Python 2.6 test Testing only Python 2.6 Testing out more sklearn like AppVeyor CI Added install to pip Add artifacts Enabled all permutations Disable 2.6, add PIL Python 2.6, 2.7 only with PIL Testing with variable dependencies Allow failure with IF ELSE With Python 3.4 Scikit-learn like appveyor CI Fixing paths Undo path fix path fix single line path fix single line 2 Using Miniconda More path fixes New wheelhouse link Added pillow to requirements.txt Added networkx to requirements.txt Add testing of 32/64-bit Python 2.7 and 3.4 to matrix Debugging Cython compile Retry with all 4 builds Updated install.ps1 file Updated based on latest python-appveyor-demo Debugging pip install Specify numpy 1.8.1 until whl is uploaded to rackspace Use skimage-wide requirements.txt file Minor comment change to trigger build Install wheel and then install from WHEELHOUSE Install six from pip Install networkx from pip Install pyparsing from pip Install pytz from pip Try using just find-links Install the binary dependencies first, then the rest Add pillow to the install list Fix appveyor.yml syntax Fix requirements.txt syntax Fix requirements.txt syntax again Fix appveyor call to initial install Fix appveyor call to initial install again Fix appveyor call to initial install yet again Install wheel Install wheel first Install wheel and nose in the appveyor requirements.txt Fix Python3 version to match python ftp site Only use cleanup decorator if available Add debug info to multiimage test More debugging information Fix handling of path separators on Windows Add another warning guard Fix warning handling for non-windows Do not use TkAgg as it may be causing alloc error Clean up echo command Allow for unclosed file warning Fix spacing in echo command
94 lines
3.1 KiB
Python
94 lines
3.1 KiB
Python
import os
|
|
|
|
import numpy as np
|
|
from numpy.testing import assert_raises, assert_equal, assert_allclose
|
|
|
|
from skimage import data_dir
|
|
from skimage.io.collection import MultiImage, ImageCollection
|
|
|
|
import six
|
|
|
|
|
|
class TestMultiImage():
|
|
|
|
def setUp(self):
|
|
# This multipage TIF file was created with imagemagick:
|
|
# convert im1.tif im2.tif -adjoin multipage.tif
|
|
paths = [os.path.join(data_dir, 'multipage.tif'),
|
|
os.path.join(data_dir, 'no_time_for_that.gif')]
|
|
self.imgs = [MultiImage(paths[0]),
|
|
MultiImage(paths[0], conserve_memory=False),
|
|
MultiImage(paths[1]),
|
|
MultiImage(paths[1], conserve_memory=False),
|
|
ImageCollection(paths[0]),
|
|
ImageCollection(paths[1], conserve_memory=False),
|
|
ImageCollection('%s:%s' % (paths[0], paths[1]))]
|
|
|
|
def test_len(self):
|
|
assert len(self.imgs[0]) == len(self.imgs[1]) == 2
|
|
assert len(self.imgs[2]) == len(self.imgs[3]) == 24
|
|
assert len(self.imgs[4]) == 2
|
|
assert len(self.imgs[5]) == 24
|
|
assert len(self.imgs[6]) == 26, len(self.imgs[6])
|
|
|
|
def test_slicing(self):
|
|
img = self.imgs[-1]
|
|
assert type(img[:]) is ImageCollection
|
|
assert len(img[:]) == 26, len(img[:])
|
|
assert len(img[:1]) == 1
|
|
assert len(img[1:]) == 25
|
|
assert_allclose(img[0], img[:1][0])
|
|
assert_allclose(img[1], img[1:][0])
|
|
assert_allclose(img[-1], img[::-1][0])
|
|
assert_allclose(img[0], img[::-1][-1])
|
|
|
|
def test_getitem(self):
|
|
for img in self.imgs:
|
|
num = len(img)
|
|
|
|
for i in range(-num, num):
|
|
assert type(img[i]) is np.ndarray
|
|
assert_allclose(img[0], img[-num])
|
|
|
|
assert_raises(AssertionError,
|
|
assert_allclose,
|
|
img[0], img[1])
|
|
|
|
# assert_raises expects a callable, hence this thin wrapper function.
|
|
def return_img(n):
|
|
return img[n]
|
|
assert_raises(IndexError, return_img, num)
|
|
assert_raises(IndexError, return_img, -num - 1)
|
|
|
|
def test_files_property(self):
|
|
for img in self.imgs:
|
|
if isinstance(img, ImageCollection):
|
|
continue
|
|
|
|
assert isinstance(img.filename, six.string_types)
|
|
|
|
def set_filename(f):
|
|
img.filename = f
|
|
assert_raises(AttributeError, set_filename, 'newfile')
|
|
|
|
def test_conserve_memory_property(self):
|
|
for img in self.imgs:
|
|
assert isinstance(img.conserve_memory, bool)
|
|
|
|
def set_mem(val):
|
|
img.conserve_memory = val
|
|
assert_raises(AttributeError, set_mem, True)
|
|
|
|
def test_concatenate(self):
|
|
for img in self.imgs:
|
|
if img[0].shape != img[-1].shape:
|
|
assert_raises(ValueError, img.concatenate)
|
|
continue
|
|
array = img.concatenate()
|
|
assert_equal(array.shape, (len(img),) + img[0].shape)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
from numpy.testing import run_module_suite
|
|
run_module_suite()
|