feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change
on this file since ac9eea7 was
ac9eea7,
checked in by Paul Brossier <piem@piem.org>, 11 years ago
|
tests/python/src/spectral/filterbank.py: replaced by python/tests/test_filterbank.py
|
-
Property mode set to
100755
|
File size:
1.5 KB
|
Rev | Line | |
---|
[75e715f] | 1 | #! /usr/bin/env python |
---|
[5e3ed60] | 2 | |
---|
[0536612] | 3 | from numpy.testing import TestCase, run_module_suite |
---|
| 4 | from numpy.testing import assert_equal, assert_almost_equal |
---|
[5e3ed60] | 5 | from numpy import random |
---|
[ac9eea7] | 6 | from math import pi |
---|
[4c01c0f] | 7 | from aubio import cvec, filterbank |
---|
[0536612] | 8 | |
---|
[5e3ed60] | 9 | class aubio_filterbank_test_case(TestCase): |
---|
[0536612] | 10 | |
---|
[5e3ed60] | 11 | def test_members(self): |
---|
[0536612] | 12 | f = filterbank(40, 512) |
---|
[5e3ed60] | 13 | assert_equal ([f.n_filters, f.win_s], [40, 512]) |
---|
[0536612] | 14 | |
---|
[5e3ed60] | 15 | def test_set_coeffs(self): |
---|
| 16 | f = filterbank(40, 512) |
---|
| 17 | r = random.random([40, 512 / 2 + 1]).astype('float32') |
---|
| 18 | f.set_coeffs(r) |
---|
| 19 | assert_equal (r, f.get_coeffs()) |
---|
[0536612] | 20 | |
---|
[ac9eea7] | 21 | def test_phase(self): |
---|
| 22 | f = filterbank(40, 512) |
---|
| 23 | c = cvec(512) |
---|
| 24 | c.phas[:] = pi |
---|
| 25 | assert_equal( f(c), 0); |
---|
| 26 | |
---|
| 27 | def test_norm(self): |
---|
| 28 | f = filterbank(40, 512) |
---|
| 29 | c = cvec(512) |
---|
| 30 | c.norm[:] = 1 |
---|
| 31 | assert_equal( f(c), 0); |
---|
| 32 | |
---|
| 33 | def test_random_norm(self): |
---|
| 34 | f = filterbank(40, 512) |
---|
| 35 | c = cvec(512) |
---|
| 36 | c.norm[:] = random.random((512 / 2 + 1,)).astype('float32') |
---|
| 37 | assert_equal( f(c), 0) |
---|
| 38 | |
---|
| 39 | def test_random_coeffs(self): |
---|
| 40 | f = filterbank(40, 512) |
---|
| 41 | c = cvec(512) |
---|
| 42 | r = random.random([40, 512 / 2 + 1]).astype('float32') |
---|
| 43 | r /= r.sum() |
---|
| 44 | f.set_coeffs(r) |
---|
| 45 | c.norm[:] = random.random((512 / 2 + 1,)).astype('float32') |
---|
| 46 | assert_equal ( f(c) < 1., True ) |
---|
| 47 | assert_equal ( f(c) > 0., True ) |
---|
| 48 | |
---|
| 49 | def test_mfcc_coeffs(self): |
---|
| 50 | f = filterbank(40, 512) |
---|
| 51 | c = cvec(512) |
---|
| 52 | f.set_mel_coeffs_slaney(44100) |
---|
| 53 | c.norm[:] = random.random((512 / 2 + 1,)).astype('float32') |
---|
| 54 | assert_equal ( f(c) < 1., True ) |
---|
| 55 | assert_equal ( f(c) > 0., True ) |
---|
| 56 | |
---|
[0536612] | 57 | if __name__ == '__main__': |
---|
| 58 | from unittest import main |
---|
| 59 | main() |
---|
| 60 | |
---|
Note: See
TracBrowser
for help on using the repository browser.