def test_resample(): rec, sort = se.example_datasets.toy_example(dump_folder='test', dumpable=True, duration=2, num_channels=4, seed=0) resample_rate_low = 0.1 * rec.get_sampling_frequency() resample_rate_high = 2 * rec.get_sampling_frequency() rec_rsl = resample(rec, resample_rate_low) rec_rsh = resample(rec, resample_rate_high) assert rec_rsl.get_num_frames() == int(rec.get_num_frames() * 0.1) assert rec_rsh.get_num_frames() == int(rec.get_num_frames() * 2) # with times times = rec.frame_to_time(np.arange(rec.get_num_frames())) - 10 times[1000:] += 0.5 rec.set_times(times) rec_rsl = resample(rec, resample_rate_low) rec_rsh = resample(rec, resample_rate_high) assert rec_rsl.get_num_frames() == int(rec.get_num_frames() * 0.1) assert rec_rsh.get_num_frames() == int(rec.get_num_frames() * 2) check_dumping(rec_rsl) check_dumping(rec_rsh) shutil.rmtree('test')
def test_resample(): rec, sort = se.example_datasets.toy_example(duration=10, num_channels=4) resample_rate_low = 0.1 * rec.get_sampling_frequency() resample_rate_high = 2 * rec.get_sampling_frequency() rec_rsl = resample(rec, resample_rate_low) rec_rsh = resample(rec, resample_rate_high) assert rec_rsl.get_num_frames() == int(rec.get_num_frames() * 0.1) assert rec_rsh.get_num_frames() == int(rec.get_num_frames() * 2)
def test_resample(): rec, sort = se.example_datasets.create_dumpable_extractors(duration=10, num_channels=4, folder='test') resample_rate_low = 0.1 * rec.get_sampling_frequency() resample_rate_high = 2 * rec.get_sampling_frequency() rec_rsl = resample(rec, resample_rate_low) rec_rsh = resample(rec, resample_rate_high) assert rec_rsl.get_num_frames() == int(rec.get_num_frames() * 0.1) assert rec_rsh.get_num_frames() == int(rec.get_num_frames() * 2) check_dumping(rec_rsl) check_dumping(rec_rsh) shutil.rmtree('test')