Ignore:
Timestamp:
Jun 22, 2016, 1:00:10 PM (9 years ago)
Author:
Paul Brossier <piem@piem.org>
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:
4b9443c4
Parents:
60fc05b (diff), 6769586 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into notes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/utils.py

    r60fc05b rf264b17  
    11#! /usr/bin/env python
    22
     3import os
     4import glob
     5import numpy as np
     6from tempfile import mkstemp
     7
    38def array_from_text_file(filename, dtype = 'float'):
    4     import os.path
    5     from numpy import array
    69    filename = os.path.join(os.path.dirname(__file__), filename)
    7     return array([line.split() for line in open(filename).readlines()],
    8         dtype = dtype)
     10    with open(filename) as f:
     11        lines = f.readlines()
     12    return np.array([line.split() for line in lines],
     13            dtype = dtype)
    914
    1015def list_all_sounds(rel_dir):
    11     import os.path, glob
    1216    datadir = os.path.join(os.path.dirname(__file__), rel_dir)
    1317    return glob.glob(os.path.join(datadir,'*.*'))
     
    2125
    2226def get_tmp_sink_path():
    23     from tempfile import mkstemp
    24     import os
    2527    fd, path = mkstemp()
    2628    os.close(fd)
     
    2830
    2931def del_tmp_sink_path(path):
    30     import os
    31     os.unlink(path)
     32    try:
     33        os.unlink(path)
     34    except WindowsError as e:
     35        print("deleting {:s} failed ({:s}), reopening".format(path, repr(e)))
     36        with open(path, 'wb') as f:
     37            f.close()
     38        try:
     39            os.unlink(path)
     40        except WindowsError as f:
     41            print("deleting {:s} failed ({:s}), aborting".format(path, repr(e)))
    3242
    3343def array_from_yaml_file(filename):
     
    4454    total_frames = 0
    4555    while True:
    46         samples, read = s()
     56        _, read = s()
    4757        total_frames += read
    4858        if read < hopsize: break
     
    5060
    5161def count_samples_in_directory(samples_dir):
    52     import os
    5362    total_frames = 0
    5463    for f in os.walk(samples_dir):
     
    6170
    6271def count_files_in_directory(samples_dir):
    63     import os
    6472    total_files = 0
    6573    for f in os.walk(samples_dir):
Note: See TracChangeset for help on using the changeset viewer.