Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
roomrys committed Jul 24, 2024
1 parent 9dddd6b commit 078c153
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions sleap/gui/suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def _max_point_displacement_video(

if n_frames < 2:
return []

# Calculate displacements
diff = labels_numpy[1:] - labels_numpy[:-1] # (frames - 1, tracks, nodes, x, y)
euc_norm = np.linalg.norm(diff, axis=-1) # (frames - 1, tracks, nodes)
Expand All @@ -337,11 +337,12 @@ def _max_point_displacement_video(
threshold_mask = np.any(
mean_euc_norm > displacement_threshold, axis=-1
) # (frames - 1,)
frame_idxs = list(np.argwhere(threshold_mask).flatten() + 1) # [0, len(frames - 1)]
frame_idxs = list(
np.argwhere(threshold_mask).flatten() + 1
) # [0, len(frames - 1)]

return cls.idx_list_to_frame_list(frame_idxs, video)


@classmethod
def frame_chunk(
cls,
Expand Down
4 changes: 3 additions & 1 deletion tests/gui/test_suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@ def test_velocity_suggestions(centered_pair_predictions):
assert suggestions[0].frame_idx == 21
assert suggestions[1].frame_idx == 45


def test_max_point_displacement_suggestions(centered_pair_predictions):
suggestions = VideoFrameSuggestions.suggest(
labels=centered_pair_predictions,
params=dict(
videos=centered_pair_predictions.videos,
method="max_point_displacement",
displacement_threshold = 6
displacement_threshold=6,
),
)
assert len(suggestions) == 19
assert suggestions[0].frame_idx == 28
assert suggestions[1].frame_idx == 82


def test_frame_increment(centered_pair_predictions: Labels):
# Testing videos that have less frames than desired Samples per Video (stride)
# Expected result is there should be n suggestions where n is equal to the frames
Expand Down

0 comments on commit 078c153

Please sign in to comment.