def test_create_label2audio_dict_valueerror_no_matching_label(): labels = set(['vacuum', 'fridge', 'wind']) paths = [ pathlib.Path('data/audio/vac/vac1.wav'), pathlib.Path('data/audio/fridg/fridg1.wav'), pathlib.Path('data/audio/vac/vac2.wav'), pathlib.Path('data/audio/win/win1.wav') ] with pytest.raises(ValueError): featorg.create_label2audio_dict(labels, paths)
def test_create_label2audio_dict_typeerror_paths(): labels = set(['vacuum', 'fridge', 'wind']) paths = str([ pathlib.Path('data/audio/vacuum/vacuum1.wav'), pathlib.Path('data/audio/fridge/fridge1.wav'), pathlib.Path('data/audio/vacuum/vacuum2.wav'), pathlib.Path('data/audio/wind/wind1.wav') ]) with pytest.raises(TypeError): featorg.create_label2audio_dict(labels, paths)
def test_create_label2audio_dict_seed(): PosixPath = pathlib.PosixPath label2audio_dict = { 'vacuum': [ PosixPath('data/audio/vacuum/vacuum2.wav'), PosixPath('data/audio/vacuum/vacuum3.wav'), PosixPath('data/audio/vacuum/vacuum4.wav') ], 'fridge': [ PosixPath('data/audio/fridge/fridge1.wav'), PosixPath('data/audio/fridge/fridge2.wav') ], 'wind': [ PosixPath('data/audio/wind/wind1.wav'), PosixPath('data/audio/wind/wind2.wav'), PosixPath('data/audio/wind/wind3.wav') ] } labels = ['vacuum', 'fridge', 'wind'] paths = [ pathlib.Path('data/audio/vacuum/vacuum1.wav'), pathlib.Path('data/audio/fridge/fridge1.wav'), pathlib.Path('data/audio/vacuum/vacuum2.wav'), pathlib.Path('data/audio/wind/wind1.wav'), pathlib.Path('data/audio/vacuum/vacuum3.wav'), pathlib.Path('data/audio/fridge/fridge2.wav'), pathlib.Path('data/audio/vacuum/vacuum4.wav'), pathlib.Path('data/audio/wind/wind2.wav'), pathlib.Path('data/audio/wind/wind3.wav') ] value_dict = featorg.create_label2audio_dict(labels, paths, limit=3, seed=15) assert label2audio_dict == value_dict
def test_create_label2audio_dict_sets(): PosixPath = pathlib.PosixPath label2audio_dict = { 'fridge': [PosixPath('data/audio/fridge/fridge1.wav')], 'wind': [PosixPath('data/audio/wind/wind1.wav')], 'vacuum': [ PosixPath('data/audio/vacuum/vacuum1.wav'), PosixPath('data/audio/vacuum/vacuum2.wav') ] } labels = set(['vacuum', 'fridge', 'wind']) paths = set([ pathlib.Path('data/audio/vacuum/vacuum1.wav'), pathlib.Path('data/audio/fridge/fridge1.wav'), pathlib.Path('data/audio/vacuum/vacuum2.wav'), pathlib.Path('data/audio/wind/wind1.wav') ]) value_dict = featorg.create_label2audio_dict(labels, paths) assert label2audio_dict == value_dict