class_docstr: The :class:`History` class helps to build a genealogy of all the
  individuals produced in the evolution. It contains two attributes,
  the :attr:`genealogy_tree` that is a dictionary of lists indexed by
  individual, the list contain the indices of the parents. The second
  attribute :attr:`genealogy_history` contains every individual indexed
  by their individual number as in the genealogy tree.
  
  The produced genealogy tree is compatible with `NetworkX
  <http://networkx.lanl.gov/index.html>`_, here is how to plot the genealogy
  tree ::
  
      history = History()
  
      # Decorate the variation operators
      toolbox.decorate("mate", history.decorator)
      toolbox.decorate("mutate", history.decorator)
  
      # Create the population and populate the history
      population = toolbox.population(n=POPSIZE)
      history.update(population)
  
      # Do the evolution, the decorators will take care of updating the
      # history
      # [...]
  
      import matplotlib.pyplot as plt
      import networkx
  
      graph = networkx.DiGraph(history.genealogy_tree)
      graph = graph.reverse()     # Make the graph top-down
      colors = [toolbox.evaluate(history.genealogy_history[i])[0] for i in graph]
      networkx.draw(graph, node_color=colors)
      plt.show()
  
  Using NetworkX in combination with `pygraphviz
  <http://networkx.lanl.gov/pygraphviz/>`_ (dot layout) this amazing
  genealogy tree can be obtained from the OneMax example with a population
  size of 20 and 5 generations, where the color of the nodes indicate their
  fitness, blue is low and red is high.
  
  .. image:: /_images/genealogy.png
     :width: 67%
  
  .. note::
     The genealogy tree might get very big if your population and/or the
     number of generation is large.
class_docstr_tok: ["The",":","class",":","`","History","`","class","helps","to","build","a","genealogy","of","all","the","individuals","produced","in","the","evolution",".","It","contains","two","attributes",",","the",":","attr",":","`","genealogy_tree","`","that","is","a","dictionary","of","lists","indexed","by","individual",",","the","list","contain","the","indices","of","the","parents",".","The","second","attribute",":","attr",":","`","genealogy_history","`","contains","every","individual","indexed","by","their","individual","number","as","in","the","genealogy","tree",".","The","produced","genealogy","tree","is","compatible","with","`","NetworkX","<","http",":","\/\/networkx.lanl.gov\/index.html",">","`","_",",","here","is","how","to","plot","the","genealogy","tree",":",":","history","=","History","(",")","#","Decorate","the","variation","operators","toolbox.decorate","(","``","mate","''",",","history.decorator",")","toolbox.decorate","(","``","mutate","''",",","history.decorator",")","#","Create","the","population","and","populate","the","history","population","=","toolbox.population","(","n=POPSIZE",")","history.update","(","population",")","#","Do","the","evolution",",","the","decorators","will","take","care","of","updating","the","#","history","#","[","...","]","import","matplotlib.pyplot","as","plt","import","networkx","graph","=","networkx.DiGraph","(","history.genealogy_tree",")","graph","=","graph.reverse","(",")","#","Make","the","graph","top-down","colors","=","[","toolbox.evaluate","(","history.genealogy_history","[","i","]",")","[","0","]","for","i","in","graph","]","networkx.draw","(","graph",",","node_color=colors",")","plt.show","(",")","Using","NetworkX","in","combination","with","`","pygraphviz","<","http",":","\/\/networkx.lanl.gov\/pygraphviz\/",">","`","_","(","dot","layout",")","this","amazing","genealogy","tree","can","be","obtained","from","the","OneMax","example","with","a","population","size","of","20","and","5","generations",",","where","the","color","of","the","nodes","indicate","their","fitness",",","blue","is","low","and","red","is","high",".","..","image",":",":","\/_images\/genealogy.png",":","width",":","67","%","..","note",":",":","The","genealogy","tree","might","get","very","big","if","your","population","and\/or","the","number","of","generation","is","large","."]
docstr: Property that returns an appropriate decorator to enhance the
  operators of the toolbox. The returned decorator assumes that the
  individuals are returned by the operator. First the decorator calls
  the underlying operation and then calls the :func:`update` function
  with what has been returned by the operator. Finally, it returns the
  individuals with their history parameters modified according to the
  update function.
docstr_tok: ["Property","that","returns","an","appropriate","decorator","to","enhance","the","operators","of","the","toolbox",".","The","returned","decorator","assumes","that","the","individuals","are","returned","by","the","operator",".","First","the","decorator","calls","the","underlying","operation","and","then","calls","the",":","func",":","`","update","`","function","with","what","has","been","returned","by","the","operator",".","Finally",",","it","returns","the","individuals","with","their","history","parameters","modified","according","to","the","update","function","."]
code: def decorator(self):
      """Property that returns an appropriate decorator to enhance the
      operators of the toolbox. The returned decorator assumes that the
      individuals are returned by the operator. First the decorator calls
      the underlying operation and then calls the :func:`update` function
      with what has been returned by the operator. Finally, it returns the
      individuals with their history parameters modified according to the
      update function.
      """
  
      def decFunc(func):
          def wrapFunc(*args, **kargs):
              individuals = func(*args, **kargs)
              self.update(individuals)
              return individuals
  
          return wrapFunc
  
      return decFunc
  
imports: from bisect import bisect_right
  from collections import defaultdict
  from copy import deepcopy
  from functools import partial
  from itertools import chain
  from operator import eq
label_desc: Use image node_id 3 for calling the History obj's underlying member method code with example usage: obj.decorator() and returns: decFunc, wrapFunc, individuals