Changeset f36ecea for python/tests
- Timestamp:
- Jan 12, 2014, 5:54:42 AM (11 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 4320679
- Parents:
- d945976
- Location:
- python/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_slicing.py
rd945976 rf36ecea 5 5 6 6 from aubio import slice_source_at_stamps 7 from utils import count_samples_in_file, count_samples_in_directory 8 from utils import get_default_test_sound 7 from utils import * 9 8 10 9 import tempfile … … 29 28 def test_slice_start_beyond_end(self): 30 29 regions_start = [i*1000 for i in range(1, n_slices)] 31 regions_start += [count_samples_in_file(self.source_file)]32 30 regions_start += [count_samples_in_file(self.source_file) + 1000] 33 31 slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir) 32 33 def test_slice_start_every_blocksize(self): 34 hopsize = 200 35 regions_start = [i*hopsize for i in range(1, n_slices)] 36 regions_start += [count_samples_in_file(self.source_file) + 1000] 37 slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir, 38 hopsize = 200) 34 39 35 40 def tearDown(self): 36 41 original_samples = count_samples_in_file(self.source_file) 37 42 written_samples = count_samples_in_directory(self.output_dir) 43 total_files = count_files_in_directory(self.output_dir) 44 assert_equal(n_slices, total_files, 45 "number of slices created different from expected") 38 46 assert_equal(written_samples, original_samples, 39 47 "number of samples written different from number of original samples") … … 68 76 69 77 def test_slice_wrong_ends(self): 70 regions_start = [i*1000 for i in range(1, 100)]78 regions_start = [i*1000 for i in range(1, n_slices)] 71 79 regions_end = [] 72 80 self.assertRaises (ValueError, … … 75 83 76 84 def test_slice_no_ends(self): 77 regions_start = [i*1000 for i in range(1, 100)]85 regions_start = [i*1000 for i in range(1, n_slices)] 78 86 regions_end = None 79 87 slice_source_at_stamps (self.source_file, regions_start, regions_end, -
python/tests/utils.py
rd945976 rf36ecea 48 48 total_frames += count_samples_in_file(file_path) 49 49 return total_frames 50 51 def count_files_in_directory(samples_dir): 52 import os 53 total_files = 0 54 for f in os.walk(samples_dir): 55 if len(f[2]): 56 for each in f[2]: 57 file_path = os.path.join(f[0], each) 58 if file_path: 59 total_files += 1 60 return total_files
Note: See TracChangeset
for help on using the changeset viewer.