@@ -77,7 +77,26 @@ def test_failure_with_non_unique_channel_ids():
7777 seed = 10
7878 rec = generate_recording (num_channels = 4 , durations = durations , set_probe = False , seed = seed )
7979 with pytest .raises (AssertionError ):
80- rec_sliced = ChannelSliceRecording (rec , channel_ids = [0 , 1 ], renamed_channel_ids = [0 , 0 ])
80+ rec_sliced = ChannelSliceRecording (rec , channel_ids = ["0" , "1" ], renamed_channel_ids = [0 , 0 ])
81+
82+
83+ def test_remove_channels ():
84+ """
85+ Check that `remove_channels` returns a recording with the correct channels removed, and that
86+ it raises an error if non-existent channels are given.
87+ """
88+ durations = [1.0 ]
89+ seed = 1205
90+
91+ # Note: generated recordings have channel ids: '0', '1', '2', '3', ...
92+ rec = generate_recording (num_channels = 4 , durations = durations , set_probe = False , seed = seed )
93+
94+ rec_sliced = rec .remove_channels (remove_channel_ids = ["0" , "2" ])
95+ rec_sliced_channel_ids = rec_sliced .get_channel_ids ()
96+ assert np .all (rec_sliced_channel_ids == np .array (["1" , "3" ]))
97+
98+ with pytest .raises (ValueError ):
99+ rec_sliced = rec .remove_channels (remove_channel_ids = [0 , "1" ])
81100
82101
83102if __name__ == "__main__" :
0 commit comments