jni / jni/affinder

Starting affinder without layers causes Napari to crash

Open
#79 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
23
Forks
13
PR merge metrics
No merged PRs in 30d

Description

When opening the "Start affinder" widgets without any active layers in the viewer:
```python
import napari

viewer = napari.Viewer()

qtwidget, widget = viewer.window.add_plugin_dock_widget(
'affinder', 'Start affinder'
)

napari.run()
```
I get this error:
```pytb
Traceback (most recent call last):
File "C:\Users\arnoldam\custom_code\affinder\examples\error-example.py", line 8, in
qtwidget, widget = viewer.window.add_plugin_dock_widget(
File "C:\Users\arnoldam\miniconda\envs\napari-main\lib\site-packages\napari\_qt\qt_main_window.py", line 811, in add_plugin_dock_widget
wdg = _instantiate_dock_widget(
File "C:\Users\arnoldam\miniconda\envs\napari-main\lib\site-packages\napari\_qt\qt_main_window.py", line 1465, in _instantiate_dock_widget
return wdg_cls(**kwargs)
File "C:\Users\arnoldam\miniconda\envs\napari-main\lib\site-packages\magicgui\type_map\_magicgui.py", line 487, in __call__
self._widget_init(widget)
File "C:\Users\arnoldam\custom_code\affinder\src\affinder\affinder.py", line 120, in _on_affinder_main_init
_update_unique_choices(widget.moving, widget.reference.current_choice)
File "C:\Users\arnoldam\custom_code\affinder\src\affinder\affinder.py", line 104, in _update_unique_choices
index = choice_names.index(choice_name)
ValueError: '' is not in list

Process finished with exit code 1
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Run the provided napari reproduction with no active layers, then read src/affinder/affinder.py at _update_unique_choices and _on_affinder_main_init, identified in the traceback. The fix is done when opening the “Start affinder” widget without layers no longer raises ValueError or crashes the viewer.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.