Ignore plotting failures in gallery plot

This commit is contained in:
mbsantiago 2025-08-08 13:30:44 +01:00
parent c3d377b6e0
commit 2341f822a7
2 changed files with 40 additions and 28 deletions

View File

@ -93,39 +93,51 @@ def plot_class_examples(
for index, match in enumerate(true_positives):
ax = plt.subplot(4, n_examples, index + 1)
plotting.plot_true_positive_match(
match,
ax=ax,
preprocessor=preprocessor,
duration=duration,
)
try:
plotting.plot_true_positive_match(
match,
ax=ax,
preprocessor=preprocessor,
duration=duration,
)
except ValueError:
continue
for index, match in enumerate(false_positives):
ax = plt.subplot(4, n_examples, n_examples + index + 1)
plotting.plot_false_positive_match(
match,
ax=ax,
preprocessor=preprocessor,
duration=duration,
)
try:
plotting.plot_false_positive_match(
match,
ax=ax,
preprocessor=preprocessor,
duration=duration,
)
except ValueError:
continue
for index, match in enumerate(false_negatives):
ax = plt.subplot(4, n_examples, 2 * n_examples + index + 1)
plotting.plot_false_negative_match(
match,
ax=ax,
preprocessor=preprocessor,
duration=duration,
)
try:
plotting.plot_false_negative_match(
match,
ax=ax,
preprocessor=preprocessor,
duration=duration,
)
except ValueError:
continue
for index, match in enumerate(cross_triggers):
ax = plt.subplot(4, n_examples, 4 * n_examples + index + 1)
plotting.plot_cross_trigger_match(
match,
ax=ax,
preprocessor=preprocessor,
duration=duration,
)
try:
plotting.plot_cross_trigger_match(
match,
ax=ax,
preprocessor=preprocessor,
duration=duration,
)
except ValueError:
continue
return fig

View File

@ -22,6 +22,8 @@ __all__ = [
"plot_cross_trigger_match",
]
DEFAULT_DURATION = 0.05
DEFAULT_FALSE_POSITIVE_COLOR = "orange"
DEFAULT_FALSE_NEGATIVE_COLOR = "red"
DEFAULT_TRUE_POSITIVE_COLOR = "green"
@ -119,9 +121,6 @@ def plot_matches(
return ax
DEFAULT_DURATION = 0.05
def plot_false_positive_match(
match: MatchEvaluation,
preprocessor: Optional[PreprocessorProtocol] = None,
@ -149,7 +148,8 @@ def plot_false_positive_match(
clip = data.Clip(
start_time=max(start_time - duration / 2, 0),
end_time=min(
start_time + duration / 2, sound_event.recording.duration
start_time + duration / 2,
sound_event.recording.duration,
),
recording=sound_event.recording,
)