示例#1
0
 def test_read_after_close(self):
     samplerate = 0 # use native samplerate
     hop_size = 256
     f = source(default_test_sound, samplerate, hop_size)
     read, frames = f()
     f.close()
     with assert_raises(RuntimeError):
         read, frames = f()
     with assert_raises(RuntimeError):
         read, frames = f.do_multi()
示例#2
0
 def test_read_after_close(self):
     samplerate = 0  # use native samplerate
     hop_size = 256
     f = source(default_test_sound, samplerate, hop_size)
     read, frames = f()
     f.close()
     with assert_raises(RuntimeError):
         read, frames = f()
     with assert_raises(RuntimeError):
         read, frames = f.do_multi()
示例#3
0
def test_process_2d_bounds():
    # behavior: _process_2d_bounds accepts all possible ways to set x and y
    # bounds in 2d plots and returns a 1d array with equally spaced
    # intervals between the lower and upper bound of the data. The number
    # of elements in the 1d array must be of one element larger than the
    # shape of the data, because it includes the upper bound.

    height, width = 20, 10
    array_data = np.ones(shape=(height, width))
    plot = Plot()

    # bounds is None : infer from array_data shape
    xs = plot._process_2d_bounds(None, array_data, 1)
    assert xs.shape[0] == width + 1
    ys = plot._process_2d_bounds(None, array_data, 0)
    assert ys.shape[0] == height + 1

    # bounds is a tuple : it defines lower and upper range
    bounds = (1.0, 100.0)
    xs = plot._process_2d_bounds(bounds, array_data, 1)
    assert xs.shape[0] == width + 1
    assert xs[0] == bounds[0] and xs[-1] == bounds[1]

    # bounds is a 1D array: the first and last elements are used to create
    # equally spaced intervals. Bounds must be of one element larger than the
    # corresponding axis in array_data, or it will raise a Value error
    bounds = np.zeros((height + 1, ))
    bounds[0], bounds[-1] = 0.2, 21.3
    ys = plot._process_2d_bounds(bounds, array_data, 0)
    assert ys.shape[0] == height + 1
    assert ys[0] == bounds[0] and ys[-1] == bounds[-1]
    with assert_raises(ValueError):
        bounds = np.zeros((width // 2, ))
        plot._process_2d_bounds(bounds, array_data, 0)

    # bounds is a 2D array: the first and last elements along the appropriate
    # axis are used to create equally spaced intervals.
    # The size of the bounds must be the same as the data array, or this
    # sill raise a ValueError
    xbounds, ybounds = np.meshgrid(np.arange(width), np.arange(height))

    xs = plot._process_2d_bounds(xbounds, array_data, 1)
    assert xs.shape[0] == width + 1
    assert xs[0] == xbounds[0, 0] and xs[-2] == xbounds[0, -1]
    with assert_raises(ValueError):
        plot._process_2d_bounds(xbounds[:5, :], array_data, 1)

    ys = plot._process_2d_bounds(ybounds, array_data, 0)
    assert ys.shape[0] == height + 1
    assert ys[0] == ybounds[0, 0] and ys[-2] == ybounds[-1, 0]
示例#4
0
def test_process_2d_bounds():
    # behavior: _process_2d_bounds accepts all possible ways to set x and y
    # bounds in 2d plots and returns a 1d array with equally spaced
    # intervals between the lower and upper bound of the data. The number
    # of elements in the 1d array must be of one element larger than the
    # shape of the data, because it includes the upper bound.

    height, width = 20, 10
    array_data = np.ones(shape=(height, width))
    plot = Plot()

    # bounds is None : infer from array_data shape
    xs = plot._process_2d_bounds(None, array_data, 1)
    assert xs.shape[0] == width + 1
    ys = plot._process_2d_bounds(None, array_data, 0)
    assert ys.shape[0] == height + 1

    # bounds is a tuple : it defines lower and upper range
    bounds = (1.0, 100.0)
    xs = plot._process_2d_bounds(bounds, array_data, 1)
    assert xs.shape[0] == width + 1
    assert xs[0] == bounds[0] and xs[-1] == bounds[1]

    # bounds is a 1D array: the first and last elements are used to create
    # equally spaced intervals. Bounds must be of one element larger than the
    # corresponding axis in array_data, or it will raise a Value error
    bounds = np.zeros((height+1, ))
    bounds[0], bounds[-1] = 0.2, 21.3
    ys = plot._process_2d_bounds(bounds, array_data, 0)
    assert ys.shape[0] == height + 1
    assert ys[0] == bounds[0] and ys[-1] == bounds[-1]
    with assert_raises(ValueError):
        bounds = np.zeros((width // 2, ))
        plot._process_2d_bounds(bounds, array_data, 0)

    # bounds is a 2D array: the first and last elements along the appropriate
    # axis are used to create equally spaced intervals.
    # The size of the bounds must be the same as the data array, or this
    # sill raise a ValueError
    xbounds, ybounds = np.meshgrid(np.arange(width), np.arange(height))

    xs = plot._process_2d_bounds(xbounds, array_data, 1)
    assert xs.shape[0] == width + 1
    assert xs[0] == xbounds[0,0] and xs[-2] == xbounds[0,-1]
    with assert_raises(ValueError):
        plot._process_2d_bounds(xbounds[:5,:], array_data, 1)

    ys = plot._process_2d_bounds(ybounds, array_data, 0)
    assert ys.shape[0] == height + 1
    assert ys[0] == ybounds[0,0] and ys[-2] == ybounds[-1,0]
示例#5
0
 def test_wrong_seek_too_large(self):
     f = source(default_test_sound)
     try:
         with assert_raises(ValueError):
             f.seek(f.duration + f.samplerate * 10)
     except:
         skipTest('seeking after end of stream failed raising ValueError')
示例#6
0
 def test_wrong_seek_too_large(self):
     f = source(default_test_sound)
     try:
         with assert_raises(ValueError):
             f.seek(f.duration + f.samplerate * 10)
     except:
         skipTest('seeking after end of stream failed raising ValueError')
示例#7
0
 def test_note2midi_unknown_values(self, note):
     " unknown values throw out an error "
     assert_raises(ValueError, note2midi, note)
示例#8
0
 def test_note2midi_unknown_values(self, note):
     " unknown values throw out an error "
     assert_raises(ValueError, note2midi, note)
示例#9
0
 def test_midi2note_floating_value(self):
     " fails when passed a floating point "
     assert_raises(TypeError, midi2note, 69.2)
示例#10
0
 def test_midi2note_negative_value(self):
     " fails when passed a negative value "
     assert_raises(ValueError, midi2note, -2)
示例#11
0
 def test_midi2note_floating_value(self):
     " fails when passed a floating point "
     assert_raises(TypeError, midi2note, 69.2)
示例#12
0
 def test_midi2note_negative_value(self):
     " fails when passed a negative value "
     assert_raises(ValueError, midi2note, -2)
示例#13
0
文件: test_sink.py 项目: aubio/aubio
 def test_wrong_channels(self):
     with assert_raises(RuntimeError):
         sink(get_tmp_sink_path(), 44100, -1)
示例#14
0
 def test_wrong_file(self):
     with assert_raises(RuntimeError):
         source('path_to/unexisting file.mp3')
示例#15
0
 def test_wrong_channels(self):
     with assert_raises(RuntimeError):
         sink(get_tmp_sink_path(), 44100, -1)
示例#16
0
 def test_wrong_seek(self):
     f = source(default_test_sound)
     with assert_raises(ValueError):
         f.seek(-1)
示例#17
0
 def test_wrong_channels(self):
     with assert_raises(ValueError):
         source(default_test_sound, 0, 0, -1)
示例#18
0
 def test_wrong_hop_size(self):
     with assert_raises(ValueError):
         source(default_test_sound, 0, -1)
示例#19
0
 def test_wrong_samplerate(self):
     with assert_raises(ValueError):
         source(default_test_sound, -1)
示例#20
0
 def test_wrong_file(self):
     with assert_raises(RuntimeError):
         source('path_to/unexisting file.mp3')
示例#21
0
 def test_wrong_samplerate(self):
     with assert_raises(ValueError):
         source(default_test_sound, -1)
示例#22
0
文件: test_sink.py 项目: aubio/aubio
 def test_wrong_samplerate_too_large(self):
     with assert_raises(RuntimeError):
         sink(get_tmp_sink_path(), 1536001, 2)
示例#23
0
 def test_wrong_hop_size(self):
     with assert_raises(ValueError):
         source(default_test_sound, 0, -1)
示例#24
0
文件: test_sink.py 项目: aubio/aubio
 def test_wrong_channels_too_large(self):
     with assert_raises(RuntimeError):
         sink(get_tmp_sink_path(), 44100, 202020)
示例#25
0
 def test_wrong_channels(self):
     with assert_raises(ValueError):
         source(default_test_sound, 0, 0, -1)
示例#26
0
 def test_midi2note_large(self):
     " fails when passed a value greater than 127 "
     assert_raises(ValueError, midi2note, 128)
示例#27
0
 def test_wrong_seek(self):
     f = source(default_test_sound)
     with assert_raises(ValueError):
         f.seek(-1)
示例#28
0
 def test_midi2note_character_value(self):
     " fails when passed a value that can not be transformed to integer "
     assert_raises(TypeError, midi2note, "a")
示例#29
0
 def test_wrong_filename(self):
     with assert_raises(RuntimeError):
         sink('')
示例#30
0
 def test_midi2note_large(self):
     " fails when passed a value greater than 127 "
     assert_raises(ValueError, midi2note, 128)
示例#31
0
 def test_wrong_samplerate_too_large(self):
     with assert_raises(RuntimeError):
         sink(get_tmp_sink_path(), 1536001, 2)
示例#32
0
 def test_midi2note_character_value(self):
     " fails when passed a value that can not be transformed to integer "
     assert_raises(TypeError, midi2note, "a")
示例#33
0
文件: test_sink.py 项目: aubio/aubio
 def test_wrong_filename(self):
     with assert_raises(RuntimeError):
         sink('')
示例#34
0
 def test_wrong_samplerate(self):
     with assert_raises(RuntimeError):
         sink(get_tmp_sink_path(), -1)
示例#35
0
文件: test_sink.py 项目: aubio/aubio
 def test_wrong_samplerate(self):
     with assert_raises(RuntimeError):
         sink(get_tmp_sink_path(), -1)
示例#36
0
 def test_read_only_member(self, name):
     o = mfcc()
     with assert_raises((TypeError, AttributeError)):
         setattr(o, name, 0)
示例#37
0
 def test_wrong_channels_too_large(self):
     with assert_raises(RuntimeError):
         sink(get_tmp_sink_path(), 44100, 202020)