class_docstr: .. include:: /global.rst
  
  Please refer to |gridsearch| for more information about this algorithm.
  
  Exhaustive search over the Cartesian product of parameter tuples.
  Returns x (the tuple which maximizes f) and its score f(x).
  
  >>> s = GridSearch(x=[1,2,3], y=[-1,0,1])
  >>> best_pars, _ = s.optimize(lambda x, y: x*y)
  >>> best_pars['x']
  3
  >>> best_pars['y']
  1
class_docstr_tok: ["..","include",":",":","\/global.rst","Please","refer","to","|gridsearch|","for","more","information","about","this","algorithm",".","Exhaustive","search","over","the","Cartesian","product","of","parameter","tuples",".","Returns","x","(","the","tuple","which","maximizes","f",")","and","its","score","f","(","x",")",".",">",">",">","s","=","GridSearch","(","x=","[","1,2,3","]",",","y=","[","-1,0,1","]",")",">",">",">","best_pars",",","_","=","s.optimize","(","lambda","x",",","y",":","x","*","y",")",">",">",">","best_pars","[","'","x","'","]","3",">",">",">","best_pars","[","'","y","'","]","1"]
docstr: Assigns equally spaced grid points with given density in [ub, lb].
  The bounds are always used. ``density`` must be at least 2.
  
  :param lb: lower bound of resulting grid
  :param ub: upper bound of resulting grid
  :param density: number of points to use
  :type lb: float
  :type ub: float
  :type density: int
  
  >>> s = GridSearch.assign_grid_points(1.0, 2.0, 3)
  >>> s #doctest:+SKIP
  [1.0, 1.5, 2.0]
docstr_tok: ["Assigns","equally","spaced","grid","points","with","given","density","in","[","ub",",","lb","]",".","The","bounds","are","always","used",".","``","density","``","must","be","at","least","2.",":","param","lb",":","lower","bound","of","resulting","grid",":","param","ub",":","upper","bound","of","resulting","grid",":","param","density",":","number","of","points","to","use",":","type","lb",":","float",":","type","ub",":","float",":","type","density",":","int",">",">",">","s","=","GridSearch.assign_grid_points","(","1.0",",","2.0",",","3",")",">",">",">","s","#","doctest",":","+SKIP","[","1.0",",","1.5",",","2.0","]"]
code: def assign_grid_points(lb, ub, density):
      """Assigns equally spaced grid points with given density in [ub, lb].
      The bounds are always used. ``density`` must be at least 2.
  
      :param lb: lower bound of resulting grid
      :param ub: upper bound of resulting grid
      :param density: number of points to use
      :type lb: float
      :type ub: float
      :type density: int
  
      >>> s = GridSearch.assign_grid_points(1.0, 2.0, 3)
      >>> s #doctest:+SKIP
      [1.0, 1.5, 2.0]
  
      """
      density = int(density)
      assert density >= 2
      step = float(ub - lb) / (density - 1)
      return [lb + i * step for i in range(density)]
  
file_path: optunity/optunity/solvers/GridSearch.py
imports: import operator
  import itertools
  from ..functions import static_key_order
  from .solver_registry import register_solver
  from .util import Solver, _copydoc, shrink_bounds
  from .None import util
label_desc: Use image node_id 2 for calling the GridSearch obj's underlying member method code with example usage: obj.assign_grid_points(lb, ub, density) and returns: unknown