[Scipy-svn] r6745 - trunk/scipy/optimize

scipy-svn@scip... scipy-svn@scip...
Sat Sep 11 19:56:55 CDT 2010


Author: ptvirtan
Date: 2010-09-11 19:56:55 -0500 (Sat, 11 Sep 2010)
New Revision: 6745

Modified:
   trunk/scipy/optimize/lbfgsb.py
Log:
3K: optimize: fix some bytes vs str issues in lbfgsb

Modified: trunk/scipy/optimize/lbfgsb.py
===================================================================
--- trunk/scipy/optimize/lbfgsb.py	2010-09-12 00:56:43 UTC (rev 6744)
+++ trunk/scipy/optimize/lbfgsb.py	2010-09-12 00:56:55 UTC (rev 6745)
@@ -27,6 +27,7 @@
 from numpy import zeros, float64, array, int32
 import _lbfgsb
 import optimize
+from numpy.compat import asbytes
 
 approx_fprime = optimize.approx_fprime
 
@@ -188,20 +189,20 @@
                        pgtol, wa, iwa, task, iprint, csave, lsave,
                        isave, dsave)
         task_str = task.tostring()
-        if task_str.startswith('FG'):
+        if task_str.startswith(asbytes('FG')):
             # minimization routine wants f and g at the current x
             n_function_evals += 1
             # Overwrite f and g:
             f, g = func_and_grad(x)
-        elif task_str.startswith('NEW_X'):
+        elif task_str.startswith(asbytes('NEW_X')):
             # new iteration
             if n_function_evals > maxfun:
                 task[:] = 'STOP: TOTAL NO. of f AND g EVALUATIONS EXCEEDS LIMIT'
         else:
             break
 
-    task_str = task.tostring().strip('\x00').strip()
-    if task_str.startswith('CONV'):
+    task_str = task.tostring().strip(asbytes('\x00')).strip()
+    if task_str.startswith(asbytes('CONV')):
         warnflag = 0
     elif n_function_evals > maxfun:
         warnflag = 1



More information about the Scipy-svn mailing list