Skip to content
Snippets Groups Projects
Commit a51d6cee authored by Andrey Aristov's avatar Andrey Aristov
Browse files

Merge branch 'interactive-widget' of...

Merge branch 'interactive-widget' of https://github.com/aaristov/napari-segment into interactive-widget
parents 1c50a782 a2cc588e
No related branches found
Tags v0.2.4
No related merge requests found
...@@ -7,13 +7,13 @@ on: ...@@ -7,13 +7,13 @@ on:
push: push:
branches: branches:
- main - main
- npe2 - interactive-widget
tags: tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request: pull_request:
branches: branches:
- main - main
- npe2 - interactive-widget
workflow_dispatch: workflow_dispatch:
jobs: jobs:
......
...@@ -35,6 +35,9 @@ install_requires = ...@@ -35,6 +35,9 @@ install_requires =
numpy numpy
scikit-image scikit-image
zarr zarr
matplotlib
dask
imageio_ffmpeg
python_requires = >=3.8 python_requires = >=3.8
include_package_data = True include_package_data = True
package_dir = package_dir =
......
from napari_segment import ExampleQWidget, example_magic_widget
import numpy as np
# make_napari_viewer is a pytest fixture that returns a napari viewer object
# capsys is a pytest fixture that captures stdout and stderr output streams
def test_example_q_widget(make_napari_viewer, capsys):
# make viewer and add an image layer using our fixture
viewer = make_napari_viewer()
viewer.add_image(np.random.random((100, 100)))
# create our widget, passing in the viewer
my_widget = ExampleQWidget(viewer)
# call our widget method
my_widget._on_click()
# read captured output and check that it's as we expected
captured = capsys.readouterr()
assert captured.out == "napari has 1 layers\n"
def test_example_magic_widget(make_napari_viewer, capsys):
viewer = make_napari_viewer()
layer = viewer.add_image(np.random.random((100, 100)))
# this time, our widget will be a MagicFactory or FunctionGui instance
my_widget = example_magic_widget()
# if we "call" this object, it'll execute our function
my_widget(viewer.layers[0])
# read captured output and check that it's as we expected
captured = capsys.readouterr()
assert captured.out == f"you have selected {layer}\n"
from napari_segment import ExampleQWidget, example_magic_widget from napari_segment import SegmentStack
import numpy as np import numpy as np
import dask.array as da
# make_napari_viewer is a pytest fixture that returns a napari viewer object # make_napari_viewer is a pytest fixture that returns a napari viewer object
# capsys is a pytest fixture that captures stdout and stderr output streams # capsys is a pytest fixture that captures stdout and stderr output streams
def test_example_q_widget(make_napari_viewer, capsys): def test_segment_stack(make_napari_viewer, capsys):
# make viewer and add an image layer using our fixture # make viewer and add an image layer using our fixture
viewer = make_napari_viewer() viewer = make_napari_viewer()
viewer.add_image(np.random.random((100, 100))) viewer.add_image(np.random.random((5, 100, 100)), name="test_data", metadata={"path": "fakepath.nd2"})
# create our widget, passing in the viewer # create our widget, passing in the viewer
my_widget = ExampleQWidget(viewer) widget = SegmentStack(viewer)
assert widget.input.current_choice == "test_data"
assert widget.path == "fakepath.nd2"
assert isinstance(widget.ddata, da.Array)
assert widget.ddata.chunks == ((1, 1, 1, 1, 1), (100/widget.binning,), (100/widget.binning,))
# call our widget method
my_widget._on_click()
# read captured output and check that it's as we expected
captured = capsys.readouterr()
assert captured.out == "napari has 1 layers\n"
def test_example_magic_widget(make_napari_viewer, capsys):
viewer = make_napari_viewer()
layer = viewer.add_image(np.random.random((100, 100)))
# this time, our widget will be a MagicFactory or FunctionGui instance
my_widget = example_magic_widget()
# if we "call" this object, it'll execute our function
my_widget(viewer.layers[0])
# read captured output and check that it's as we expected # read captured output and check that it's as we expected
captured = capsys.readouterr() # captured = capsys.readouterr()
assert captured.out == f"you have selected {layer}\n" # assert captured.out == "napari has 1 layers\n"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment