Skip to content

Commit

Permalink
Modify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebi06 committed Jan 5, 2024
1 parent d98cba4 commit e54d111
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src/czitools/_tests/test_napari_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import napari
from pathlib import Path
from typing import List, Dict, Tuple, Optional, Type, Any, Union, Mapping
from typing import List, Dict, Tuple, Optional, Type, Any, Union, Mapping, Literal
import os

# check if the test in executed as part of a GITHUB action
Expand Down Expand Up @@ -33,13 +33,17 @@ def test_rename_sliders(
# exclude the test when executed inside a GITHUB action
@pytest.mark.skipif(IN_GITHUB_ACTIONS, reason="Test doesn't work in Github Actions.")
@pytest.mark.parametrize(
"czifile, num_layers",
"czifile, num_layers, show_metadata, wdname",
[
("w96_A1+A2.czi", 2),
("w96_A1+A2.czi", 2, "tree", "MetadataTree"),
("CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi", 2, "table", "MetadataTable"),
],
)
def test_show_image(czifile: str, num_layers: int) -> None:
"""Test that the `show` function correctly displays a two-channel image."""
def test_show_image(czifile: str,
num_layers: int,
show_metadata: Literal["none", "tree", "table"],
wdname: str) -> None:
"""Test that the `show` function correctly displays a two-channel image and the metadada widgets."""

filepath = basedir / "data" / czifile
md = metadata_tools.CziMetadata(filepath)
Expand All @@ -63,10 +67,13 @@ def test_show_image(czifile: str, num_layers: int) -> None:
blending="additive",
contrast="from_czi",
gamma=0.85,
show_metadata="tree",
show_metadata=show_metadata,
name_sliders=True,
)

# Check that a tree widget is visible in the viewer
assert (wdname in viewer.window.__dict__["_dock_widgets"].data.keys()) is True

# Check that the layer is present in the viewer
assert len(viewer.layers) == num_layers

Expand All @@ -75,6 +82,6 @@ def test_show_image(czifile: str, num_layers: int) -> None:
assert isinstance(viewer.layers[layer], napari.layers.Image)

# Check that the layer's data is the same as the input image
np.testing.assert_array_equal(viewer.layers[layer].data, array6d[:, :, layer:layer+1, :, :, :])
np.testing.assert_array_equal(viewer.layers[layer].data, array6d[:, :, layer:layer + 1, :, :, :])

viewer.close()
1 change: 0 additions & 1 deletion src/czitools/napari_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def show(
- "napari_auto" : Let Napari figure out a display scaling. Will look in the center of an image!
- "from_czi" : use the display scaling from ZEN stored inside the CZI metadata. Defaults to "calc".
gamma (float, optional): gamma value for the Viewer for all layers Defaults to 0.85.
add_mdtable (bool, optional): option to show the CziMetadata. Defaults to True.
show_metadata (mdviewoption, optional): Option to show metadata as tree or table. Defaults to "tree".
name_sliders (bool, optional): option to use the dimension letters as slider labels for the viewer. Defaults to False.
dask_cache_size(float, optional): option to resize the dask cache used for opportunistic caching. Range [0 - 1]
Expand Down

0 comments on commit e54d111

Please sign in to comment.