From 820e145b335fff1d77fbf689ca86cf13684f860a Mon Sep 17 00:00:00 2001 From: Talmo Pereira Date: Mon, 16 Dec 2024 15:12:44 -0800 Subject: [PATCH 1/2] Make node marker and label sizes configurable via preferences --- sleap/gui/app.py | 5 +++-- sleap/prefs.py | 16 +++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/sleap/gui/app.py b/sleap/gui/app.py index 575b082b7..2709e86db 100644 --- a/sleap/gui/app.py +++ b/sleap/gui/app.py @@ -656,17 +656,18 @@ def prev_vid(): key="edge style", ) + # XXX add_submenu_choices( menu=viewMenu, title="Node Marker Size", - options=(1, 2, 4, 6, 8, 12), + options=prefs["node marker sizes"], key="marker size", ) add_submenu_choices( menu=viewMenu, title="Node Label Size", - options=(6, 12, 18, 24, 36), + options=prefs["node label sizes"], key="node label size", ) diff --git a/sleap/prefs.py b/sleap/prefs.py index 8790f1d3f..e043afc44 100644 --- a/sleap/prefs.py +++ b/sleap/prefs.py @@ -28,6 +28,8 @@ class Preferences(object): "node label size": 12, "show non-visible nodes": True, "share usage data": True, + "node marker sizes": (1, 2, 3, 4, 6, 8, 12), + "node label sizes": (6, 9, 12, 18, 24, 36), } _filename = "preferences.yaml" @@ -43,14 +45,14 @@ def load_(self): """Load preferences from file (regardless of whether loaded already).""" try: self._prefs = util.get_config_yaml(self._filename) - if not hasattr(self._prefs, "get"): - self._prefs = self._defaults - else: - self._prefs["trail length"] = self._prefs.get( - "trail length", self._defaults["trail length"] - ) except FileNotFoundError: - self._prefs = self._defaults + pass + + self._prefs = self._prefs or {} + + for k, v in self._defaults.items(): + if k not in self._prefs: + self._prefs[k] = v def save(self): """Save preferences to file.""" From df7f0cb6cbeed59a586a28a16f45a2963fcb7c69 Mon Sep 17 00:00:00 2001 From: Talmo Pereira Date: Mon, 16 Dec 2024 15:47:28 -0800 Subject: [PATCH 2/2] Fix test --- tests/gui/test_commands.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/gui/test_commands.py b/tests/gui/test_commands.py index fb5637407..e19e00236 100644 --- a/tests/gui/test_commands.py +++ b/tests/gui/test_commands.py @@ -863,14 +863,13 @@ def test_DeleteFrameLimitPredictions( context.state["video"] = centered_pair_vid # Set-up params for the command - params = {"frame_idx_threshold": 900} + params = {"min_frame_idx": 900, "max_frame_idx": 1000} - expected_instances = 423 - predicted_instances = DeleteFrameLimitPredictions.get_frame_instance_list( + instances_to_delete = DeleteFrameLimitPredictions.get_frame_instance_list( context, params ) - assert len(predicted_instances) == expected_instances + assert len(instances_to_delete) == 2070 @pytest.mark.parametrize("export_extension", [".json.zip", ".slp"])