Skip to content

Commit 317daac

Browse files
committed
Cover the unmatched model case and drop a redundant reset.
Reassigning the dropdown choices already resets the value, so the explicit fallback never ran.
1 parent e2a7c20 commit 317daac

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

cellfinder/napari/train/train.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,7 @@ def widget(
179179

180180
@widget.dimensions.changed.connect
181181
def update_pretrained_model_choices(dimensions: int):
182-
choices = models_for_dimensions(dimensions)
183-
widget.pretrained_model.choices = choices
184-
if widget.pretrained_model.value not in choices:
185-
widget.pretrained_model.value = choices[0]
182+
widget.pretrained_model.choices = models_for_dimensions(dimensions)
186183

187184
@widget.reset_button.changed.connect
188185
def restore_defaults():

tests/core/test_unit/test_download.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ def test_default_model_matches_mode(dimensions, has_background, expected):
5353
assert download.default_model(dimensions, has_background) == expected
5454

5555

56+
def test_default_model_without_a_registered_match():
57+
with pytest.raises(ValueError, match="No pretrained model"):
58+
download.default_model(4, True)
59+
60+
5661
def test_validate_model_dimensions_rejects_mismatch():
5762
with pytest.raises(ValueError, match="is 2D, but dimensions=3"):
5863
download.validate_model_dimensions("resnet50_2d", 3)

0 commit comments

Comments
 (0)