[Scipy-svn] r6842 - trunk/scipy/special

scipy-svn@scip... scipy-svn@scip...
Sat Oct 16 19:22:39 CDT 2010


Author: warren.weckesser
Date: 2010-10-16 19:22:38 -0500 (Sat, 16 Oct 2010)
New Revision: 6842

Modified:
   trunk/scipy/special/basic.py
Log:
BUG: special: sinc(0) should not cause a warning.

Modified: trunk/scipy/special/basic.py
===================================================================
--- trunk/scipy/special/basic.py	2010-10-14 15:39:40 UTC (rev 6841)
+++ trunk/scipy/special/basic.py	2010-10-17 00:22:38 UTC (rev 6842)
@@ -11,8 +11,13 @@
 def sinc(x):
     """Returns sin(pi*x)/(pi*x) at all points of array x.
     """
-    w = asarray(asarray(x)*pi)
-    return where(x==0, 1.0, sin(w)/w)
+    w = pi * asarray(x)
+    # w might contain 0, and so temporarily turn off warnings
+    # while calculating sin(w)/w.
+    old_settings = seterr(all='ignore')
+    s = sin(w) / w
+    seterr(**old_settings)
+    return where(x==0, 1.0, s)
 
 def diric(x,n):
     """Returns the periodic sinc function also called the dirichlet function:



More information about the Scipy-svn mailing list