-
Notifications
You must be signed in to change notification settings - Fork 27
Plugin refactor [7]: Fix trajectory plot, better interactions #183
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
Merged
C-Achard
merged 36 commits into
cy/feature-refactor-2026
from
cy/refactor-fix-traj-plot-y-axis-rebased
Apr 27, 2026
Merged
Changes from 8 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
56947fc
Observe Points and sync trajectory plot
C-Achard 53746d6
Add PointsInteractionObserver and traj UI tests
C-Achard 616eb75
Apply napari theme to matplotlib canvas and toolbar
C-Achard 1be979d
Improve trajectory plot widget sizing and layout
C-Achard 864f698
Make trajectory plot robust to incomplete Points
C-Achard 0829f64
Rename KeypointMatplotlibCanvas to TrajectoryMatplotlibCanvas
C-Achard ccbd912
Update test_points_layers.py
C-Achard 1e4423f
Update _widgets.py
C-Achard 0980fcd
Use qtbot.add_widget and wait in tests
C-Achard 105839f
Update src/napari_deeplabcut/ui/plots/trajectory.py
C-Achard f3751e4
Improve widget teardown, event docs, and size
C-Achard 55dad3b
Improve points-layer UI tweaks and update tests
C-Achard 64e8865
Mark except blocks as no-cover in color patch
C-Achard c6d3729
Update test_widgets.py
C-Achard 78e4f59
Make points/plot handling more robust
C-Achard 68e9639
Add unit tests for cropping UI module
C-Achard 2beef5a
Support individual-based coloring in trajectory plot
C-Achard 9c6f62c
Support multi-animal color cycles in trajectory plot
C-Achard 20d9aa2
Update tests for bodypart mode and line keys
C-Achard ce26ca2
Prefer active DLC Points layer for plotting
C-Achard c6d230b
Use preferred_paths in frame inference
C-Achard f5a830f
Enhance label progress reporting and UI
C-Achard 2b8394f
Add info button and clarify progress wording
C-Achard a8043ec
Update _widgets dev notes
C-Achard d700140
Fix formatting and newline in layer_stats text
C-Achard ad37c33
Replace layer info icon
C-Achard ec4b061
Add TODO to move models.py to core/
C-Achard 6250e76
Prevent duplicate KeypointControls opening
C-Achard c77c73b
Add debug recorder and environment utilities
C-Achard 1f20060
Add build_debug_report helper
C-Achard 69b0879
Add DebugTextWindow UI for diagnostics
C-Achard 980eda1
Add debug window and move properties to top
C-Achard ce00bc1
Specify napari-dlc in menus; fix debug window
C-Achard 6e5587d
Add debug logging to KeypointControls
C-Achard c23381b
Allow smaller log buffer and return POSIX paths
C-Achard a886812
Add tests for debug window and debug utils
C-Achard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import numpy as np | ||
| import pytest | ||
|
|
||
| from napari_deeplabcut.ui.plots.trajectory import TrajectoryMatplotlibCanvas | ||
|
|
||
|
|
||
| @pytest.mark.e2e | ||
| @pytest.mark.usefixtures("qtbot") | ||
| def test_sync_visible_lines_to_points_selection_shows_all_when_no_points_selected(viewer, qtbot): | ||
| layer = viewer.add_points( | ||
| np.array([[0, 0], [1, 1]]), | ||
| properties={"label": np.array(["nose", "tail"], dtype=object)}, | ||
| ) | ||
|
|
||
| canvas = TrajectoryMatplotlibCanvas(viewer) | ||
| qtbot.addWidget(canvas) | ||
|
|
||
|
C-Achard marked this conversation as resolved.
|
||
| # Avoid relying on df creation for this focused visibility test | ||
| canvas.df = object() | ||
| (line_nose,) = canvas.ax.plot([0, 1], [0, 1]) | ||
| (line_tail,) = canvas.ax.plot([0, 1], [1, 0]) | ||
| canvas._lines = { | ||
| "nose": [line_nose], | ||
| "tail": [line_tail], | ||
| } | ||
|
C-Achard marked this conversation as resolved.
C-Achard marked this conversation as resolved.
|
||
|
|
||
| layer.selected_data.clear() | ||
| canvas.sync_visible_lines_to_points_selection() | ||
|
|
||
| assert line_nose.get_visible() is True | ||
| assert line_tail.get_visible() is True | ||
|
|
||
|
|
||
| @pytest.mark.e2e | ||
| @pytest.mark.usefixtures("qtbot") | ||
| def test_sync_visible_lines_to_points_selection_filters_by_selected_labels(viewer, qtbot): | ||
| layer = viewer.add_points( | ||
| np.array([[0, 0], [1, 1], [2, 2]]), | ||
| properties={"label": np.array(["nose", "tail", "nose"], dtype=object)}, | ||
| ) | ||
|
|
||
| canvas = TrajectoryMatplotlibCanvas(viewer) | ||
| qtbot.addWidget(canvas) | ||
|
|
||
| canvas.df = object() | ||
| (line_nose,) = canvas.ax.plot([0, 1], [0, 1]) | ||
| (line_tail,) = canvas.ax.plot([0, 1], [1, 0]) | ||
| canvas._lines = { | ||
| "nose": [line_nose], | ||
| "tail": [line_tail], | ||
| } | ||
|
|
||
| # Select a point whose label is "tail" | ||
| layer.selected_data.select_only(1) | ||
| canvas.sync_visible_lines_to_points_selection() | ||
|
|
||
| assert line_nose.get_visible() is False | ||
| assert line_tail.get_visible() is True | ||
|
|
||
|
|
||
| @pytest.mark.e2e | ||
| @pytest.mark.usefixtures("qtbot") | ||
| def test_sync_visible_lines_to_points_selection_shows_label_if_any_selected_point_has_that_label(viewer, qtbot): | ||
| layer = viewer.add_points( | ||
| np.array([[0, 0], [1, 1], [2, 2]]), | ||
| properties={"label": np.array(["nose", "tail", "nose"], dtype=object)}, | ||
| ) | ||
|
|
||
| canvas = TrajectoryMatplotlibCanvas(viewer) | ||
| qtbot.addWidget(canvas) | ||
|
|
||
| canvas.df = object() | ||
| (line_nose,) = canvas.ax.plot([0, 1], [0, 1]) | ||
| (line_tail,) = canvas.ax.plot([0, 1], [1, 0]) | ||
| canvas._lines = { | ||
| "nose": [line_nose], | ||
| "tail": [line_tail], | ||
| } | ||
|
|
||
| # Select both nose points | ||
| layer.selected_data.update({0, 2}) | ||
| canvas.sync_visible_lines_to_points_selection() | ||
|
|
||
| assert line_nose.get_visible() is True | ||
| assert line_tail.get_visible() is False | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.