[Scipy-svn] r2419 - in trunk/Lib/sandbox/cdavid: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Fri Dec 15 08:36:50 EST 2006
Author: cdavid
Date: 2006-12-15 07:36:44 -0600 (Fri, 15 Dec 2006)
New Revision: 2419
Modified:
trunk/Lib/sandbox/cdavid/autocorr.py
trunk/Lib/sandbox/cdavid/tests/test_autocorr.py
trunk/Lib/sandbox/cdavid/tests/test_segmentaxis.py
Log:
One day, maybe, I will be able to get nextpow2 right....
Modified: trunk/Lib/sandbox/cdavid/autocorr.py
===================================================================
--- trunk/Lib/sandbox/cdavid/autocorr.py 2006-12-15 10:59:09 UTC (rev 2418)
+++ trunk/Lib/sandbox/cdavid/autocorr.py 2006-12-15 13:36:44 UTC (rev 2419)
@@ -1,5 +1,5 @@
#! /usr/bin/env python
-# Last Change: Tue Dec 12 07:00 PM 2006 J
+# Last Change: Fri Dec 15 10:00 PM 2006 J
# TODO: - proper test
# TODO: - proper profiling
@@ -281,10 +281,11 @@
def nextpow2(n):
"""Returns p such as 2 ** p >= n """
- if 2 ** N.log2(n) == n:
- return N.floor(N.log2(n)) + 1
+ p = N.floor(N.log2(n))
+ if 2 ** p == n:
+ return p
else:
- return N.floor(N.log2(n)) + 2
+ return p + 1
def autocorr_fft(signal, axis = -1):
"""Return full autocorrelation along specified axis. Use fft
Modified: trunk/Lib/sandbox/cdavid/tests/test_autocorr.py
===================================================================
--- trunk/Lib/sandbox/cdavid/tests/test_autocorr.py 2006-12-15 10:59:09 UTC (rev 2418)
+++ trunk/Lib/sandbox/cdavid/tests/test_autocorr.py 2006-12-15 13:36:44 UTC (rev 2419)
@@ -1,5 +1,5 @@
#! /usr/bin/env python
-# Last Change: Tue Dec 12 07:00 PM 2006 J
+# Last Change: Fri Dec 15 10:00 PM 2006 J
from numpy.testing import *
from numpy.random import randn, seed
@@ -12,7 +12,7 @@
set_package_path()
from cdavid.autocorr import _raw_autocorr_1d, _raw_autocorr_1d_noncontiguous
from cdavid.autocorr import autocorr_oneside_nofft as autocorr
-from cdavid.autocorr import autocorr_fft
+from cdavid.autocorr import autocorr_fft , nextpow2
from cdavid.autocorr import _autocorr_oneside_nofft_py as autocorr_py
restore_path()
Modified: trunk/Lib/sandbox/cdavid/tests/test_segmentaxis.py
===================================================================
--- trunk/Lib/sandbox/cdavid/tests/test_segmentaxis.py 2006-12-15 10:59:09 UTC (rev 2418)
+++ trunk/Lib/sandbox/cdavid/tests/test_segmentaxis.py 2006-12-15 13:36:44 UTC (rev 2419)
@@ -1,12 +1,12 @@
#! /usr/bin/env python
-# Last Change: Fri Nov 24 04:00 PM 2006 J
+# Last Change: Fri Dec 15 10:00 PM 2006 J
from numpy.testing import *
import numpy as N
set_package_path()
-from segmentaxis import segment_axis
+from cdavid.segmentaxis import segment_axis
restore_path()
# #Optional:
More information about the Scipy-svn
mailing list