source: python/tests/utils.py @ 2693655

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 2693655 was 2693655, checked in by Paul Brossier <piem@piem.org>, 12 years ago

python/tests/utils.py: add array_from_yaml_file

  • Property mode set to 100644
File size: 598 bytes
RevLine 
[a4cc8e5]1#! /usr/bin/env python
2
3def array_from_text_file(filename, dtype = 'float'):
[e1bfde5]4    import os.path
5    from numpy import array
6    filename = os.path.join(os.path.dirname(__file__), filename)
7    return array([line.split() for line in open(filename).readlines()],
8        dtype = dtype)
[a4cc8e5]9
[e1bfde5]10def list_all_sounds(rel_dir):
11    import os.path, glob
12    datadir = os.path.join(os.path.dirname(__file__), rel_dir)
13    return glob.glob(os.path.join(datadir,'*.*'))
[2693655]14
15def array_from_yaml_file(filename):
16    import yaml
17    f = open(filename)
18    yaml_data = yaml.safe_load(f)
19    f.close()
20    return yaml_data
Note: See TracBrowser for help on using the repository browser.