Skip to content

Commit

Permalink
Merge pull request SpikeInterface#2286 from zm711/traces-widget
Browse files Browse the repository at this point in the history
Prevent users from providing a time_range after the ending of the segment in `plot_traces`
  • Loading branch information
alejoe91 authored Dec 4, 2023
2 parents 7f204c6 + a87f34b commit a39e329
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/spikeinterface/widgets/traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ def __init__(
if time_range is None:
time_range = (0, 1.0)
time_range = np.array(time_range)
if time_range[1] > rec0.get_duration(segment_index=segment_index):
warnings.warn(
"You have selected a time after the end of the segment. The range will be clipped to "
f"{rec0.get_duration(segment_index=segment_index)}"
)
time_range[1] = rec0.get_duration(segment_index=segment_index)

assert mode in ("auto", "line", "map"), 'Mode must be one of "auto","line", "map"'
if mode == "auto":
Expand Down

0 comments on commit a39e329

Please sign in to comment.