ref: ee092a8841988350d41095b42a01c4d9f5424563
parent: c2a39af80b04ff60e0c4681eb6e9941983fbec12
author: Paul Brossier <piem@piem.org>
date: Fri Apr 29 17:07:05 EDT 2016
python/tests/test_fft.py: add some memory tests
--- a/python/tests/test_fft.py
+++ b/python/tests/test_fft.py
@@ -106,6 +106,36 @@
plot ( this )
show ()
+ def test_local_fftgrain(self):
+ """ check aubio.fft() result can be accessed after deletion """
+ def compute_grain(impulse):
+ win_s = 1024
+ timegrain = fvec(win_s)
+ timegrain[0] = impulse
+ f = fft(win_s)
+ fftgrain = f ( timegrain )
+ return fftgrain
+ impulse = pi
+ fftgrain = compute_grain(impulse)
+ assert_equal ( fftgrain.phas[0], 0)
+ assert_almost_equal ( fftgrain.phas[1], 0)
+ assert_almost_equal ( fftgrain.norm[0], impulse, decimal = 6 )
+
+ def test_local_reconstruct(self):
+ """ check aubio.fft.rdo() result can be accessed after deletion """
+ def compute_grain(impulse):
+ win_s = 1024
+ timegrain = fvec(win_s)
+ timegrain[0] = impulse
+ f = fft(win_s)
+ fftgrain = f ( timegrain )
+ r = f.rdo(fftgrain)
+ return r
+ impulse = pi
+ r = compute_grain(impulse)
+ assert_almost_equal ( r[0], impulse, decimal = 6)
+ assert_almost_equal ( r[1:], 0)
+
if __name__ == '__main__':
from unittest import main
main()