Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurmasson committed Jun 28, 2024
1 parent 80c4a27 commit 58e66c4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ package_dir =

# add your package requirements here
install_requires =
exodeepfinder
exodeepfinder==0.2.4
numpy==1.26.4
magicgui==0.8.2
QtPy==2.4.1
Expand Down
3 changes: 3 additions & 0 deletions src/napari_exodeepfinder/_cluster_widget.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import napari.layers.labels
import napari.layers.labels.labels
import napari.layers.shapes
from qtpy.QtWidgets import QWidget, QGridLayout, QComboBox, QPushButton, QLabel, QGroupBox, QVBoxLayout, QTextEdit, \
QSpinBox, QFileDialog, QLineEdit
from qtpy import QtCore
Expand Down
4 changes: 2 additions & 2 deletions src/napari_exodeepfinder/_orthoview_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,10 @@ def sync_layer(self, event, init=False, layer: Optional[layers.Layer] = None, in
layer = event.source
# handle name change in a "dirty" way
index = index_of_layer(self.main_view, layer)
if layer.name != self.old_layer_names[index]:
self.old_layer_names = [layer.name for layer in self.main_view.layers]
if type(index) != bool and layer.name != self.old_layer_names[index]:
for view in secondary_viewers:
view.layers[index].name = layer.name
self.old_layer_names[index] = layer.name
# TODO: could this be done with copy?
if isinstance(layer, image):
for view in secondary_viewers:
Expand Down
18 changes: 9 additions & 9 deletions src/napari_exodeepfinder/_tests/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_add_points(make_napari_viewer, qtbot):
my_widget._input_layer_box.setCurrentText("test_layer")
assert np.array_equal(viewer.layers["test_layer"].data, np.empty([0, 3]))
qtbot.mouseClick(my_widget._add_point, QtCore.Qt.LeftButton)
assert np.array_equal(viewer.layers["test_layer"].data, np.array([[256., 256., 256.]]))
assert np.array_equal(viewer.layers["test_layer"].data, np.array([[255., 255., 255.]]))
my_widget.deleteLater()
qtbot.wait(10)

Expand Down Expand Up @@ -150,11 +150,11 @@ def test_orthoslice_click(make_napari_viewer, qtbot, Event):
my_widget.checkbox.setChecked(True)
my_widget._on_click_checkbox(True)
# test start position
assert my_widget.x == 50
assert my_widget.y == 50
assert my_widget.z == 10
assert np.array_equal(viewer.layers[-1].data, np.array([[[50, 0, 10], [0, 100-1, 0]],
[[0, 50, 10], [100-1, 0, 0]]]))
assert my_widget.x == 50-1
assert my_widget.y == 50-1
assert my_widget.z == 10-1
assert np.array_equal(viewer.layers[-1].data, np.array([[[50-1, 0, 10-1], [0, 100-1, 0]],
[[0, 50-1, 10-1], [100-1, 0, 0]]]))
# click and test end position
# Simulate click
click_event = Event(
Expand All @@ -166,9 +166,9 @@ def test_orthoslice_click(make_napari_viewer, qtbot, Event):
my_widget.mouse_single_click(my_widget.main_view, click_event)
assert my_widget.x == 75
assert my_widget.y == 75
assert my_widget.z == 10
assert np.array_equal(viewer.layers[-1].data, np.array([[[75, 0, 10], [0, 100-1, 0]],
[[0, 75, 10], [100-1, 0, 0]]]))
assert my_widget.z == 10-1
assert np.array_equal(viewer.layers[-1].data, np.array([[[75, 0, 10-1], [0, 100-1, 0]],
[[0, 75, 10-1], [100-1, 0, 0]]]))
# Insert a layer while in orthoslice view
viewer.add_image(data=np.random.random((100, 100, 20)), name='test')
assert my_widget.yz_view.layers[-2].name == 'test'
Expand Down

0 comments on commit 58e66c4

Please sign in to comment.