Changeset 2a14820


Ignore:
Timestamp:
May 2, 2016, 2:51:32 PM (8 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:
cdfad0c6
Parents:
37ca459
Message:

python/tests/test_filterbank.py: clean up, use nose2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_filterbank.py

    r37ca459 r2a14820  
    11#! /usr/bin/env python
    22
    3 from numpy.testing import TestCase, run_module_suite
     3from numpy.testing import TestCase
    44from numpy.testing import assert_equal, assert_almost_equal
    5 from numpy import random
    6 from math import pi
    7 from numpy import array
     5import numpy as np
    86from aubio import cvec, filterbank, float_type
    97from utils import array_from_text_file
     
    1715  def test_set_coeffs(self):
    1816    f = filterbank(40, 512)
    19     r = random.random([40, int(512 / 2) + 1]).astype(float_type)
     17    r = np.random.random([40, int(512 / 2) + 1]).astype(float_type)
    2018    f.set_coeffs(r)
    2119    assert_equal (r, f.get_coeffs())
     
    2422    f = filterbank(40, 512)
    2523    c = cvec(512)
    26     c.phas[:] = pi
     24    c.phas[:] = np.pi
    2725    assert_equal( f(c), 0);
    2826
     
    3634    f = filterbank(40, 512)
    3735    c = cvec(512)
    38     c.norm[:] = random.random((int(512 / 2) + 1,)).astype(float_type)
     36    c.norm[:] = np.random.random((int(512 / 2) + 1,)).astype(float_type)
    3937    assert_equal( f(c), 0)
    4038
    4139  def test_random_coeffs(self):
    42     f = filterbank(40, 512)
    43     c = cvec(512)
    44     r = random.random([40, int(512 / 2) + 1]).astype(float_type)
     40    win_s = 128
     41    f = filterbank(40, win_s)
     42    c = cvec(win_s)
     43    r = np.random.random([40, int(win_s / 2) + 1]).astype(float_type)
    4544    r /= r.sum()
    4645    f.set_coeffs(r)
    47     c.norm[:] = random.random((int(512 / 2) + 1,)).astype(float_type)
     46    c.norm[:] = np.random.random((int(win_s / 2) + 1,)).astype(float_type)
    4847    assert_equal ( f(c) < 1., True )
    4948    assert_equal ( f(c) > 0., True )
     
    5352    c = cvec(512)
    5453    f.set_mel_coeffs_slaney(44100)
    55     c.norm[:] = random.random((int(512 / 2) + 1,)).astype(float_type)
     54    c.norm[:] = np.random.random((int(512 / 2) + 1,)).astype(float_type)
    5655    assert_equal ( f(c) < 1., True )
    5756    assert_equal ( f(c) > 0., True )
     
    6463
    6564if __name__ == '__main__':
    66   from unittest import main
    67   main()
     65    from nose2 import main
     66    main()
    6867
Note: See TracChangeset for help on using the changeset viewer.