[Numpy-svn] r3426 - trunk/numpy/lib

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Nov 2 10:12:36 CST 2006


Author: oliphant
Date: 2006-11-02 10:12:34 -0600 (Thu, 02 Nov 2006)
New Revision: 3426

Modified:
   trunk/numpy/lib/function_base.py
Log:
Fix #369: windows returning invalid results for M=1

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2006-11-02 16:07:43 UTC (rev 3425)
+++ trunk/numpy/lib/function_base.py	2006-11-02 16:12:34 UTC (rev 3426)
@@ -920,24 +920,40 @@
 def blackman(M):
     """blackman(M) returns the M-point Blackman window.
     """
+    if M < 1:
+        return array([])
+    if M == 1:
+        return ones(1, float)
     n = arange(0,M)
     return 0.42-0.5*cos(2.0*pi*n/(M-1)) + 0.08*cos(4.0*pi*n/(M-1))
 
 def bartlett(M):
     """bartlett(M) returns the M-point Bartlett window.
     """
+    if M < 1:
+        return array([])
+    if M == 1:
+        return ones(1, float)
     n = arange(0,M)
     return where(less_equal(n,(M-1)/2.0),2.0*n/(M-1),2.0-2.0*n/(M-1))
 
 def hanning(M):
     """hanning(M) returns the M-point Hanning window.
     """
+    if M < 1:
+        return array([])
+    if M == 1:
+        return ones(1, float)
     n = arange(0,M)
     return 0.5-0.5*cos(2.0*pi*n/(M-1))
 
 def hamming(M):
     """hamming(M) returns the M-point Hamming window.
     """
+    if M < 1:
+        return array([])
+    if M == 1:
+        return ones(1,float)
     n = arange(0,M)
     return 0.54-0.46*cos(2.0*pi*n/(M-1))
 



More information about the Numpy-svn mailing list