def opt_grid(params, func, limits, ftol=<NUM_LIT>, disp=<NUM_LIT:0>, compute_errors=True):
caches = [[] for p in params]<EOL>newparams = numpy.copy(params)<EOL>errors = [[] for p in params]<EOL>for i, p in enumerate(params):<EOL><INDENT>cache = []<EOL>def func1(x0):<EOL><INDENT>newparams[i] = x0<EOL>v = func(newparams)<EOL>cache.append([x0, v])<EOL>return v<EOL><DEDENT>lo, hi = limits[i]<EOL>bestval = optimize(func1, x0=p,<EOL>cons=[lambda x: x - lo, lambda x: hi - x],<EOL>ftol=ftol, disp=disp - <NUM_LIT:1>)<EOL>beststat = func1(bestval)<EOL>if compute_errors:<EOL><INDENT>errors[i] = cache2errors(func1, cache, disp=disp - <NUM_LIT:1>)<EOL><DEDENT>newparams[i] = bestval<EOL>caches[i] = cache<EOL>if disp > <NUM_LIT:0>:<EOL><INDENT>if compute_errors:<EOL><INDENT>print('<STR_LIT>' % (<EOL>i, bestval, errors[i][<NUM_LIT:0>], errors[i][<NUM_LIT:1>], beststat))<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>' %<EOL>(i, bestval, beststat))<EOL><DEDENT><DEDENT><DEDENT>beststat = func(newparams)<EOL>if disp > <NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT>' % (beststat))<EOL><DEDENT>if compute_errors:<EOL><INDENT>return newparams, errors<EOL><DEDENT>else:<EOL><INDENT>return newparams<EOL><DEDENT>
see :func:`optimize1d.optimize`, considers each parameter in order

:param ftol: 
        difference in values at which the function can be considered flat
:param compute_errors:
        compute standard deviation of gaussian around optimum