Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash that occurs when no detectors are present #140

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions LabGym/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ def delete(self) -> None:


def get_detector_names() -> list[str]:
"""Return the names of all saved detectors."""
"""Return the names of all saved detectors in sorted order."""
ignore = ["__pycache__", "__init__", "__init.py__"]
return [path.name for path in DETECTOR_FOLDER.glob("*") if path.is_dir() and path.name not in ignore]
return sorted([path.name for path in DETECTOR_FOLDER.glob("*") if path.is_dir() and path.name not in ignore])


def get_annotation_class_names(annotation_path: str) -> list[str]:
Expand Down
3 changes: 1 addition & 2 deletions LabGym/gui/analysis/analyze_behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def select_method(self, event):
if self.behavior_mode <= 1:
methods = [
"Use trained Detectors (versatile but slow)",
"Subtract background (fast but requires static background & stable illumination)",
"Subtract background (fast but requires static background & stable illumination)",
]
else:
methods = ["Use trained Detectors (versatile but slow)"]
Expand Down Expand Up @@ -612,7 +612,6 @@ def select_method(self, event):
self.animal_number = {}

detectors = get_detector_names()
detectors.sort()
if "Choose a new directory of the Detector" not in detectors:
detectors.append("Choose a new directory of the Detector")

Expand Down
2 changes: 1 addition & 1 deletion LabGym/gui/training/detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def delete_detector(self, event):
self,
message="Select a Detector to delete",
caption="Delete a Detector",
choices=get_detector_names().sort(),
choices=get_detector_names(),
)
if dialog.ShowModal() != wx.ID_OK:
dialog.Destroy()
Expand Down