Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleITK and PIL tests are testing with tifffile #7305

Open
lagru opened this issue Jan 22, 2024 · 0 comments
Open

SimpleITK and PIL tests are testing with tifffile #7305

lagru opened this issue Jan 22, 2024 · 0 comments
Labels

Comments

@lagru
Copy link
Member

lagru commented Jan 22, 2024

Description:

If plugin=None (default) and a path ending in .tif are passed to skimage.io.imread the plugin order is ignored because of these lines

if plugin is None and hasattr(fname, 'lower'):
if fname.lower().endswith(('.tiff', '.tif')):
plugin = 'tifffile'

This looks like unintended behavior at a first glance. Because at least one test in test_pil.py is "secretly" using tifffile's imread. The autofixture calling and setting the plugin order via use_plugin("pil") has no effect here.

Forcing the correct plugin with plugin="pil" in this line will make the test fail because of the wrong dtype >u2 (big) were apparently <u2 (little) is expected? I'm not sure if this is the original intention of the test...

Test output

def test_imread_uint16_big_endian():
        expected = np.load(fetch('data/chessboard_GRAY_U8.npy'))
        img = imread(fetch('data/chessboard_GRAY_U16B.tif'), plugin="pil")
>       assert img.dtype == np.uint16
E       AssertionError: assert dtype('>u2') == <class 'numpy.uint16'>
E        +  where dtype('>u2') = array([[255, 255, 255, ...,   0,   0,   0],\n       [255, 255, 255, ...,   0,   0,   0],\n       [255, 255, 255, ...,   0,   0,   0],\n       ...,\n       [  0,   0,   0, ..., 255, 255, 255],\n       [  0,   0,   0, ..., 255, 255, 255],\n       [  0,   0,   0, ..., 255, 255, 255]], dtype='>u2').dtype
E        +  and   <class 'numpy.uint16'> = np.uint16

skimage/io/tests/test_pil.py:171: AssertionError

Putting a raise in tifffile's imread shows that the following tests use the wrong plugin:

FAILED test_pil.py::test_imread_separate_channels[False] - RuntimeError
FAILED test_pil.py::test_imread_separate_channels[True] - RuntimeError
FAILED test_pil.py::test_imread_multipage_rgb_tif - RuntimeError
FAILED test_pil.py::test_imread_uint16 - RuntimeError
FAILED test_pil.py::test_imread_uint16_big_endian - RuntimeError
FAILED test_simpleitk.py::test_imread_uint16 - RuntimeError
FAILED test_simpleitk.py::test_imread_uint16_big_endian - RuntimeError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant