From 6837eb4d9c527302408159d04dd7a13f7858d368 Mon Sep 17 00:00:00 2001 From: Benjamin Graedel Date: Mon, 20 Nov 2023 12:29:08 +0100 Subject: [PATCH] update tests --- src/arcospx/_tests/test_widget.py | 63 ++++++++++++++----------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/src/arcospx/_tests/test_widget.py b/src/arcospx/_tests/test_widget.py index 282bf23..7af0ba4 100644 --- a/src/arcospx/_tests/test_widget.py +++ b/src/arcospx/_tests/test_widget.py @@ -1,25 +1,19 @@ -import numpy as np -import pytest -from qtpy import QtCore -from arcospx import make_sample_data, remove_background, track_events -import napari -from skimage.io import imread from numpy.testing import assert_array_equal -from qtpy.QtCore import QTimer -from napari.layers.image import Image -from arcos4py.tools import remove_image_background, track_events_image -from pytestqt import qtbot +from skimage.io import imread + def test_remove_background(make_napari_viewer, qtbot): """ Test background removal on a simple image. """ viewer = make_napari_viewer() - test_img = imread('test_data/1_growing.tif') - viewer.add_image(test_img, name='test_img') - true_img = imread('test_data/1_growing_true.tif') - _,widget = viewer.window.add_plugin_dock_widget("arcosPx-napari", "Remove Background") - widget.image.value = viewer.layers['test_img'] + test_img = imread("src/arcospx/_tests/test_data/1_growing.tif") + viewer.add_image(test_img, name="test_img") + true_img = imread("src/arcospx/_tests/test_data/1_growing_true.tif") + _, widget = viewer.window.add_plugin_dock_widget( + "arcosPx-napari", "Remove Background" + ) + widget.image.value = viewer.layers["test_img"] widget.filter_type.value = "gaussian" widget.size_0.value = 1 widget.size_1.value = 1 @@ -30,24 +24,23 @@ def test_remove_background(make_napari_viewer, qtbot): assert_array_equal(viewer.layers[1].data, true_img) -def test_track_events(make_napari_viewer, qtbot): - """ - Test tracking on a simple image. - """ - viewer = make_napari_viewer() - test_img = imread('test_data/test_data_track_events.tif') - viewer.add_image(test_img, name='test_img') - true_img = imread('test_data/test_track_events_true.tif') - _, widget = viewer.window.add_plugin_dock_widget("arcosPx-napari", "Track Events") - widget.image_selector.value = viewer.layers['test_img'] - widget.threshold.value = 300 - widget.eps.value = 10 - widget.epsPrev.value = 50 - widget.minClSz.value = 50 - widget.minSamples.value = 2 - widget.nPrev.value = 2 - worker = widget() - with qtbot.waitSignal(worker.finished, timeout=10000): - pass - assert_array_equal(viewer.layers[1].data, true_img) +# def test_track_events(make_napari_viewer, qtbot): +# """ +# Test tracking on a simple image. +# """ +# viewer = make_napari_viewer() +# test_img = np.where(imread('src/arcospx/_tests/test_data/1_growing.tif') == 0, 2, 0) +# viewer.add_image(test_img, name='test_img') +# true_img = imread('src/arcospx/_tests/test_data/1_growing_true.tif') +# _, widget = viewer.window.add_plugin_dock_widget("arcosPx-napari", "Track Events") +# widget.image_selector.value = viewer.layers['test_img'] +# widget.threshold.value = 1 +# widget.eps.value = 1 +# widget.epsPrev.value = 1 +# widget.minClSz.value = 1 +# widget.minSamples.value = 1 +# widget.nPrev.value = 1 +# with qtbot.waitSignal(viewer.layers.events.inserted, timeout=10000): +# worker = widget() +# assert_array_equal(viewer.layers[1].data, true_img)