Skip to content

Commit

Permalink
Add a multipage tiff test and cleanup test_tifffile
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed May 13, 2015
1 parent e240dff commit dfaab19
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions skimage/io/tests/test_tifffile.py
@@ -1,45 +1,49 @@
import os
import skimage as si
import skimage.io as sio
from ... import data_dir
from .. import imread, imsave, use_plugin, reset_plugins
import numpy as np

from numpy.testing import (
assert_array_equal, assert_array_almost_equal, run_module_suite)

from tempfile import NamedTemporaryFile

_plugins = sio.plugin_order()
sio.use_plugin('tifffile')


np.random.seed(0)
def setup():
use_plugin('tifffile')
np.random.seed(0)


def teardown():
sio.reset_plugins()
reset_plugins()


def test_imread_uint16():
expected = np.load(os.path.join(si.data_dir, 'chessboard_GRAY_U8.npy'))
img = sio.imread(os.path.join(si.data_dir, 'chessboard_GRAY_U16.tif'))
expected = np.load(os.path.join(data_dir, 'chessboard_GRAY_U8.npy'))
img = imread(os.path.join(data_dir, 'chessboard_GRAY_U16.tif'))
assert img.dtype == np.uint16
assert_array_almost_equal(img, expected)


def test_imread_uint16_big_endian():
expected = np.load(os.path.join(si.data_dir, 'chessboard_GRAY_U8.npy'))
img = sio.imread(os.path.join(si.data_dir, 'chessboard_GRAY_U16B.tif'))
expected = np.load(os.path.join(data_dir, 'chessboard_GRAY_U8.npy'))
img = imread(os.path.join(data_dir, 'chessboard_GRAY_U16B.tif'))
assert img.dtype == np.uint16
assert_array_almost_equal(img, expected)


def test_imread_multipage_rgb_tif():
img = imread(os.path.join(data_dir, 'multipage_rgb.tif'))
assert img.shape == (2, 10, 10, 3), img.shape


class TestSave:
def roundtrip(self, dtype, x):
f = NamedTemporaryFile(suffix='.tif')
fname = f.name
f.close()
sio.imsave(fname, x)
y = sio.imread(fname)
imsave(fname, x)
y = imread(fname)
assert_array_equal(x, y)

def test_imsave_roundtrip(self):
Expand Down

0 comments on commit dfaab19

Please sign in to comment.