3 from numpy.testing import TestCase
4 from numpy.testing.utils import assert_almost_equal
5 from aubio import window
7 class aubio_window(TestCase):
9 def test_accept_name_and_size(self):
10 window("default", 1024)
12 def test_fail_name_not_string(self):
18 self.fail('non-string window type does not raise a ValueError')
20 def test_fail_size_not_int(self):
22 window("default", "default")
26 self.fail('non-integer window length does not raise a ValueError')
28 def test_compute_hanning_1024(self):
29 from numpy import cos, arange
32 aubio_window = window("hanning", size)
33 numpy_window = .5 - .5 * cos(2. * pi * arange(size) / size)
34 assert_almost_equal(aubio_window, numpy_window)
36 if __name__ == '__main__':
37 from unittest import main