[Scipy-svn] r7098 - trunk/scipy/fftpack

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Jan 29 14:02:01 EST 2011


Author: warren.weckesser
Date: 2011-01-29 13:02:01 -0600 (Sat, 29 Jan 2011)
New Revision: 7098

Modified:
   trunk/scipy/fftpack/helper.py
Log:
ENH: fftpack: Don't use plain assert for argument validation.

Modified: trunk/scipy/fftpack/helper.py
===================================================================
--- trunk/scipy/fftpack/helper.py	2011-01-29 18:48:18 UTC (rev 7097)
+++ trunk/scipy/fftpack/helper.py	2011-01-29 19:02:01 UTC (rev 7098)
@@ -3,7 +3,7 @@
 from numpy import array
 from numpy.fft.helper import fftshift, ifftshift, fftfreq
 
-def rfftfreq(n,d=1.0):
+def rfftfreq(n, d=1.0):
     """ rfftfreq(n, d=1.0) -> f
 
     DFT sample frequencies (for usage with rfft,irfft).
@@ -15,5 +15,6 @@
       f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2]/(d*n)   if n is even
       f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2,n/2]/(d*n)   if n is odd
     """
-    assert isinstance(n,int)
+    if not isinstance(n, int) or n < 0:
+        raise ValueError("n = %s is not valid.  n must be a nonnegative integer." % n)
     return (array(range(1,n+1),dtype=int)//2)/float(n*d)




More information about the Scipy-svn mailing list