update fft.py tests, merge from banane
authorPaul Brossier <piem@piem.org>
Wed, 7 Nov 2007 15:51:42 +0000 (16:51 +0100)
committerPaul Brossier <piem@piem.org>
Wed, 7 Nov 2007 15:51:42 +0000 (16:51 +0100)
1  2 
tests/python/fft.py

index b856238f5280d0a4f6394c70fa39ba5eac83dee1,329caa9e76dd7dc58c3783067e433c267ef9c3ae..f94f9cfc9464eb05a06fd73073f497f6c4ae0379
@@@ -83,15 -82,15 +82,21 @@@ class fft_unit(aubio_unit_template)
      for index in range(buf_size/2+1):
        for channel in range(1, channels):
          self.assertEqual(0., cvec_read_norm(fftgrain, channel, index))
++        self.assertEqual(0., cvec_read_phas(fftgrain, channel, index))
++
      # check norm and phase == 0 in first first and last bin of first channel
-     self.assertAlmostEqual((buf_size-1)*some_constant, cvec_read_norm(fftgrain, 0, 0), precision)
-     self.assertEqual(0., cvec_read_phas(fftgrain, 0, 0))
-     self.assertEqual(0., cvec_read_norm(fftgrain, 0, buf_size/2+1))
-     self.assertEqual(0., cvec_read_phas(fftgrain, 0, buf_size/2+1))
-     # check unwrap2pi(phas) ~= pi everywhere but in first bin
 -    self.assertCloseEnough((buf_size-1)*some_constant, cvec_read_norm(fftgrain, 0, 0))
++    # check unwrap2pi(phas) ~= pi everywhere but in first and last bin
+     self.assertCloseEnough(0., cvec_read_phas(fftgrain, 0, 0))
 -    self.assertCloseEnough(0., cvec_read_norm(fftgrain, 0, buf_size/2+1))
++    for index in range(1,buf_size/2):
++       self.assertCloseEnough(math.pi, aubio_unwrap2pi(cvec_read_phas(fftgrain, 0, index)))
++    self.assertCloseEnough(0., cvec_read_phas(fftgrain, 0, buf_size/2))
+     self.assertCloseEnough(0., cvec_read_phas(fftgrain, 0, buf_size/2+1))
 -    # check unwrap2pi(phas) ~= pi everywhere but in first bin
++
++    self.assertCloseEnough((buf_size-1)*some_constant, cvec_read_norm(fftgrain, 0, 0))
      for index in range(1,buf_size/2+1):
-        self.assertAlmostEqual ( math.pi, aubio_unwrap2pi(cvec_read_phas(fftgrain, 0, index)), precision)
-        self.assertAlmostEqual(some_constant, cvec_read_norm(fftgrain, 0, index), precision)
 -       self.assertCloseEnough(math.pi, aubio_unwrap2pi(cvec_read_phas(fftgrain, 0, index)))
 -       self.assertCloseEnough(some_constant, cvec_read_norm(fftgrain, 0, index))
++       self.assertCloseEnough(some_constant, abs(cvec_read_norm(fftgrain, 0, index)))
++    self.assertCloseEnough(0., cvec_read_norm(fftgrain, 0, buf_size/2+1))
++
      del fftgrain
      del input