Skip to content

Commit

Permalink
Prevent another crash
Browse files Browse the repository at this point in the history
When there are too few tracks at some timestamp.
  • Loading branch information
walles committed Aug 13, 2021
1 parent 4772e98 commit 819ace7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,15 @@ def update_badnesses(
badnesses: Dict[str, Badness], movements: List[TrackWithFloat]
) -> None:
if not movements:
# Nothing to see here, move along. Also, the median() call below throws
# an exception if called with no data.
# Nothing to see here, move along. Also, the median() call in the
# BadnessCalculator constructor throws an exception if called with no
# data.
return

if len(movements) < 4:
# To detect outliers we want a median, with one track on each side to
# set the baseline, plus a fourth track that is potentially outlying.
# With fewer tracks than that the badness score becomes too uncertain.
return

# For each track, keep track of the worst badness score so far
Expand Down

0 comments on commit 819ace7

Please sign in to comment.