[Scipy-svn] r6559 - in trunk/scipy/optimize: . tests

scipy-svn@scip... scipy-svn@scip...
Mon Jun 21 14:42:59 CDT 2010


Author: warren.weckesser
Date: 2010-06-21 14:42:59 -0500 (Mon, 21 Jun 2010)
New Revision: 6559

Modified:
   trunk/scipy/optimize/tests/test_zeros.py
   trunk/scipy/optimize/zeros.py
Log:
BUG: optimize: add missing import of warnings tp zeros.py.

Modified: trunk/scipy/optimize/tests/test_zeros.py
===================================================================
--- trunk/scipy/optimize/tests/test_zeros.py	2010-06-21 16:20:41 UTC (rev 6558)
+++ trunk/scipy/optimize/tests/test_zeros.py	2010-06-21 19:42:59 UTC (rev 6559)
@@ -2,7 +2,8 @@
 
 from math import sqrt
 
-from numpy.testing import *
+from numpy.testing import TestCase, assert_almost_equal, assert_warns, \
+                            run_module_suite
 
 from scipy.optimize import zeros as cc
 
@@ -28,6 +29,10 @@
     def test_brenth(self):
         self.run_check(cc.brenth, 'brenth')
 
+    def test_deriv_zero_warning(self):
+        func = lambda x: x**2
+        dfunc = lambda x: 2*x
+        assert_warns(RuntimeWarning, cc.newton, func, 0.0, dfunc)
 
 if __name__ == '__main__' :
     run_module_suite()

Modified: trunk/scipy/optimize/zeros.py
===================================================================
--- trunk/scipy/optimize/zeros.py	2010-06-21 16:20:41 UTC (rev 6558)
+++ trunk/scipy/optimize/zeros.py	2010-06-21 19:42:59 UTC (rev 6559)
@@ -1,3 +1,6 @@
+
+import warnings
+
 import _zeros
 from numpy import finfo
 
@@ -95,7 +98,7 @@
         p0 = x0
         for iter in range(maxiter):
             myargs = (p0,) + args
-            fval = func(*myargs)
+            # fval = func(*myargs)
             fder = fprime(*myargs)
             if fder == 0:
                 msg = "derivative was zero."



More information about the Scipy-svn mailing list