Exemplo n.º 1
0
def test_size_functions(resources_dir, filename, s, t, c, z, y, x):
    # Get file
    f = resources_dir / filename

    # Check that there are no open file pointers
    proc = Process()
    assert str(f) not in [f.path for f in proc.open_files()]

    # Init reader
    img = LifReader(f)

    # Check that there are no open file pointers after init
    proc = Process()
    assert str(f) not in [f.path for f in proc.open_files()]

    # Check sizes
    assert img.size_s() == s
    assert img.size_t() == t
    assert img.size_c() == c
    assert img.size_z() == z
    assert img.size_y() == y
    assert img.size_x() == x

    # Check that there are no open file pointers
    assert str(f) not in [f.path for f in proc.open_files()]
Exemplo n.º 2
0
def test_lif_reader(
    resources_dir,
    filename,
    expected_shape,
    expected_dims,
    expected_dtype,
    select_scene,
    chunk_dims,
):
    # Get file
    f = resources_dir / filename
    # Check that there are no open file pointers
    proc = Process()
    assert str(f) not in [f.path for f in proc.open_files()]

    # Read file
    img = LifReader(f, chunk_by_dims=chunk_dims, S=select_scene)

    # Check that there are no open file pointers after init
    assert str(f) not in [f.path for f in proc.open_files()]

    # Check basics
    assert img.dims == expected_dims
    assert img.metadata
    assert img.shape == expected_shape
    assert img.dask_data.shape == expected_shape
    assert img.size(expected_dims) == expected_shape
    assert img.dtype() == expected_dtype

    # Will error because those dimensions don't exist in the file
    with pytest.raises(exceptions.InvalidDimensionOrderingError):
        assert img.size("ABCDEFG") == expected_shape

    # Check that there are no open file pointers after basics
    assert str(f) not in [f.path for f in proc.open_files()]

    # Check array
    assert isinstance(img.data, np.ndarray)
    assert img.data.shape == expected_shape

    # Check that there are no open file pointers after retrieval
    assert str(f) not in [f.path for f in proc.open_files()]
Exemplo n.º 3
0
def test_get_channel_names(resources_dir, filename, scene, expected):
    f = resources_dir / filename

    # Check that there are no open file pointers
    proc = Process()
    assert str(f) not in [f.path for f in proc.open_files()]

    assert LifReader(resources_dir / filename).get_channel_names(scene) == expected

    # Check that there are no open file pointers
    assert str(f) not in [f.path for f in proc.open_files()]
Exemplo n.º 4
0
def test_lif_image_data_two(resources_dir, filename, scene, expected):
    f = resources_dir / filename

    # Check that there are no open file pointers
    proc = Process()
    assert str(f) not in [f.path for f in proc.open_files()]
    img = LifReader(f)

    assert img._chunk_offsets[0][0, 0, 0] == expected

    # Check that there are no open file pointers
    assert str(f) not in [f.path for f in proc.open_files()]
Exemplo n.º 5
0
def test_get_physical_pixel_size(resources_dir, filename, scene, expected):
    f = resources_dir / filename

    # Check that there are no open file pointers
    proc = Process()
    assert str(f) not in [f.path for f in proc.open_files()]

    assert LifReader(resources_dir /
                     filename).get_physical_pixel_size(scene) == pytest.approx(
                         expected, rel=0.001)

    # Check that there are no open file pointers
    assert str(f) not in [f.path for f in proc.open_files()]
Exemplo n.º 6
0
def test_lif_reader(
    resources_dir,
    filename,
    expected_shape,
    expected_dims,
    expected_dtype,
    select_scene,
    chunk_dims,
):
    # Get file
    f = resources_dir / filename
    # Check that there are no open file pointers
    proc = Process()
    assert str(f) not in [f.path for f in proc.open_files()]

    # Read file
    img = LifReader(f, chunk_by_dims=chunk_dims, S=select_scene)

    # Check that there are no open file pointers after init
    assert str(f) not in [f.path for f in proc.open_files()]

    # Check basics
    assert img.dims == expected_dims
    assert img.metadata
    assert img.dask_data.shape == expected_shape
    assert img.dtype() == expected_dtype

    # Check that there are no open file pointers after basics
    assert str(f) not in [f.path for f in proc.open_files()]

    # Check array
    assert isinstance(img.data, np.ndarray)
    assert img.data.shape == expected_shape

    # Check that there are no open file pointers after retrieval
    assert str(f) not in [f.path for f in proc.open_files()]
Exemplo n.º 7
0
def test_is_this_type(raw_bytes, expected):
    res = LifReader._is_this_type(raw_bytes)
    assert res == expected