Skip to content

Commit 442629f

Browse files
committed
add tests
1 parent 2914abd commit 442629f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/spikeinterface/core/tests/test_baserecording.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,27 @@ def test_time_slice():
412412
assert np.allclose(sliced_recording_times.get_traces(), sliced_recording_frames.get_traces())
413413

414414

415+
def test_out_of_range_time_slice():
416+
recording = generate_recording(durations=[0.100]) # duration = 0.1 s
417+
recording.shift_times(1.0) # shifts start time to 1.0 s, end time to 1.1 s
418+
419+
# start_time before recording
420+
with pytest.raises(ValueError, match="start_time .* is before the start time"):
421+
recording.time_slice(start_time=0, end_time=None)
422+
423+
# end_time before start of recording
424+
with pytest.raises(ValueError, match="end_time .* is before the start time"):
425+
recording.time_slice(start_time=None, end_time=0.5)
426+
427+
# start_time after end of recording
428+
with pytest.raises(ValueError, match="start_time .* is after the end time"):
429+
recording.time_slice(start_time=2.0, end_time=None)
430+
431+
# end_time after end of recording
432+
with pytest.raises(ValueError, match="end_time .* is after the end time"):
433+
recording.time_slice(start_time=None, end_time=2.0)
434+
435+
415436
def test_time_slice_with_time_vector():
416437

417438
# Case with time vector

0 commit comments

Comments
 (0)