Skip to content

Commit

Permalink
debut tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yrkim98 committed Nov 26, 2024
1 parent 9d5d26a commit 0e6e711
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
7 changes: 7 additions & 0 deletions src/allencell_ml_segmenter/_tests/fakes/fake_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, viewer: Optional[napari.Viewer] = None):
self._shapes_layers: Dict[str, ShapesLayer] = {}
self._labels_layers: Dict[str, LabelsLayer] = {}
self._on_layers_change_fns: List[Callable] = []
self._segmentation_inserted: Dict[str, np.ndarray] = {}

def add_image(self, image: np.ndarray, name: str):
self._image_layers[name] = ImageLayer(name, None)
Expand Down Expand Up @@ -103,3 +104,9 @@ def subscribe_layers_change_event(
def _on_layers_change(self):
for fn in self._on_layers_change_fns:
fn(FakeNapariEvent())

def get_seg_layers(self, layer_list: list[Layer]) -> list[Layer]:
return []

def insert_segmentation(self, layer_name: str, img: np.ndarray) -> None:
self._segmentation_inserted[layer_name] = img
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

from PyQt5.QtCore import Qt

from allencell_ml_segmenter._tests.fakes.fake_experiments_model import FakeExperimentsModel
from allencell_ml_segmenter.main.main_model import MainModel
from allencell_ml_segmenter.thresholding.thresholding_model import ThresholdingModel
from allencell_ml_segmenter.core.file_input_model import FileInputModel, InputMode
from allencell_ml_segmenter.main.i_experiments_model import IExperimentsModel
from allencell_ml_segmenter.main.i_viewer import FakeViewer # Assuming this exists
from allencell_ml_segmenter.prediction.prediction_folder_progress_tracker import PredictionFolderProgressTracker
from allencell_ml_segmenter.views.thresholding_view import ThresholdingView
from allencell_ml_segmenter._tests.fakes.fake_viewer import FakeViewer
from allencell_ml_segmenter.thresholding.thresholding_view import ThresholdingView

@pytest.fixture
def main_model() -> MainModel:
Expand All @@ -30,8 +29,8 @@ def file_input_model(tmp_path: Path) -> FileInputModel:
return model

@pytest.fixture
def experiments_model() -> IExperimentsModel:
return IExperimentsModel()
def experiments_model() -> FakeExperimentsModel:
return FakeExperimentsModel()

@pytest.fixture
def viewer() -> FakeViewer:
Expand Down
16 changes: 6 additions & 10 deletions src/allencell_ml_segmenter/thresholding/thresholding_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,6 @@ def _configure_slots(self) -> None:
self._update_slider_from_spinbox
)

# enable selections when corresponding radio button is selected
self._specific_value_radio_button.toggled.connect(
lambda checked: self._enable_specific_threshold_widgets(checked)
)
self._autothreshold_radio_button.toggled.connect(
lambda checked: self._autothreshold_method_combo.setEnabled(
checked
)
)

# update state and ui based on radio button selections
self._none_radio_button.toggled.connect(self._update_state_from_radios)
self._specific_value_radio_button.toggled.connect(
Expand Down Expand Up @@ -245,7 +235,13 @@ def _update_state_from_radios(self) -> None:
update state based on thresholding radio button selection
"""
self._thresholding_model.set_autothresholding_enabled(self._autothreshold_radio_button.isChecked())
self._autothreshold_method_combo.setEnabled(
self._autothreshold_radio_button.isChecked())

self._thresholding_model.set_threshold_enabled(self._specific_value_radio_button.isChecked())
self._enable_specific_threshold_widgets(self._specific_value_radio_button.isChecked())



self._apply_save_button.setEnabled(
self._specific_value_radio_button.isChecked()
Expand Down

0 comments on commit 0e6e711

Please sign in to comment.