[Scipy-svn] r2399 - in trunk/Lib/sandbox/cdavid: . tests

scipy-svn at scipy.org scipy-svn at scipy.org
Tue Dec 12 08:13:59 EST 2006


Author: cdavid
Date: 2006-12-12 07:13:53 -0600 (Tue, 12 Dec 2006)
New Revision: 2399

Modified:
   trunk/Lib/sandbox/cdavid/Changelog
   trunk/Lib/sandbox/cdavid/autocorr.py
   trunk/Lib/sandbox/cdavid/info.py
   trunk/Lib/sandbox/cdavid/tests/test_autocorr.py
Log:
Correct bug in nextpow2

Modified: trunk/Lib/sandbox/cdavid/Changelog
===================================================================
--- trunk/Lib/sandbox/cdavid/Changelog	2006-12-12 12:31:43 UTC (rev 2398)
+++ trunk/Lib/sandbox/cdavid/Changelog	2006-12-12 13:13:53 UTC (rev 2399)
@@ -1,3 +1,10 @@
+cdavid (0.2.1) Tue, 12 Dec 2006 17:14:18 +0900
+
+	* Correct bug in nextpow2 which causes circular
+	autocorrelation problem
+
+-- David Cournapeau <david at ar.media.kyoto-u.ac.jp> 
+
 cdavid (0.2) Tue, 12 Dec 2006 17:14:18 +0900
 
 	* second release

Modified: trunk/Lib/sandbox/cdavid/autocorr.py
===================================================================
--- trunk/Lib/sandbox/cdavid/autocorr.py	2006-12-12 12:31:43 UTC (rev 2398)
+++ trunk/Lib/sandbox/cdavid/autocorr.py	2006-12-12 13:13:53 UTC (rev 2399)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Tue Dec 12 05:00 PM 2006 J
+# Last Change: Tue Dec 12 07:00 PM 2006 J
 
 # TODO: - proper test
 # TODO: - proper profiling
@@ -282,9 +282,9 @@
 def nextpow2(n):
     """Returns p such as 2 ** p >= n """
     if 2 ** N.log2(n) ==  n:
-        return int(N.log2(n))
+        return N.floor(N.log2(n)) + 1
     else:
-        return int(N.log2(n) + 1)
+        return N.floor(N.log2(n)) + 2
 
 def autocorr_fft(signal, axis = -1):
     """Return full autocorrelation along specified axis. Use fft

Modified: trunk/Lib/sandbox/cdavid/info.py
===================================================================
--- trunk/Lib/sandbox/cdavid/info.py	2006-12-12 12:31:43 UTC (rev 2398)
+++ trunk/Lib/sandbox/cdavid/info.py	2006-12-12 13:13:53 UTC (rev 2399)
@@ -4,7 +4,7 @@
 Copyright: David Cournapeau 2006
 License: BSD-style (see LICENSE.txt in main source directory)
 """
-version = '0.1'
+version = '0.2.1'
 
 depends = ['linalg']
 ignore  = False

Modified: trunk/Lib/sandbox/cdavid/tests/test_autocorr.py
===================================================================
--- trunk/Lib/sandbox/cdavid/tests/test_autocorr.py	2006-12-12 12:31:43 UTC (rev 2398)
+++ trunk/Lib/sandbox/cdavid/tests/test_autocorr.py	2006-12-12 13:13:53 UTC (rev 2399)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Tue Dec 12 05:00 PM 2006 J
+# Last Change: Tue Dec 12 07:00 PM 2006 J
 
 from numpy.testing import *
 from numpy.random import randn, seed
@@ -294,6 +294,11 @@
 class test_autocorr_fft(NumpyTestCase):
     n   = 5
     d   = 3
+    def check_nextpow2(self):
+        assert(nextpow2(255) == 8)
+        assert(nextpow2(256) == 8)
+        assert(nextpow2(257) == 9)
+
     def check_r1r(self):
         """real case, rank 1"""
         a   = randn(self.n)




More information about the Scipy-svn mailing list