Skip to content

Commit

Permalink
Merge pull request DEAP#414 from loganthomas/doc_updates
Browse files Browse the repository at this point in the history
Docstring updates
  • Loading branch information
fmder authored Mar 1, 2020
2 parents f86583f + 7d28cca commit d714385
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions deap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def __init__(self):
def register(self, alias, function, *args, **kargs):
"""Register a *function* in the toolbox under the name *alias*. You
may provide default arguments that will be passed automatically when
calling the registered function. Fixed arguments can then be overriden
calling the registered function. Fixed arguments can then be overridden
at function call time.
:param alias: The name the operator will take in the toolbox. If the
alias already exist it will overwrite the the operator
alias already exist it will overwrite the operator
already present.
:param function: The function to which refer the alias.
:param argument: One or more argument (and keyword argument) to pass
Expand Down Expand Up @@ -124,7 +124,7 @@ def decorate(self, alias, *decorators):

class Fitness(object):
"""The fitness is a measure of quality of a solution. If *values* are
provided as a tuple, the fitness is initalized using those values,
provided as a tuple, the fitness is initialized using those values,
otherwise it is empty (or invalid).
:param values: The initial values of the fitness as a tuple, optional.
Expand Down
4 changes: 2 additions & 2 deletions deap/cma.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,10 @@ def _select(self, candidates):
mid_front = None
not_chosen = list()

# Fill the next population (chosen) with the fronts until there is not enouch space
# Fill the next population (chosen) with the fronts until there is not enough space
# When an entire front does not fit in the space left we rely on the hypervolume
# for this front
# The remaining fronts are explicitely not chosen
# The remaining fronts are explicitly not chosen
full = False
for front in pareto_fronts:
if len(chosen) + len(front) <= self.mu and not full:
Expand Down
2 changes: 1 addition & 1 deletion deap/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __deepcopy__(self, memo):
@staticmethod
def __new__(cls, iterable):
"""Creates a new instance of a numpy.ndarray from a function call.
Adds the possibility to instanciate from an iterable."""
Adds the possibility to instantiate from an iterable."""
return numpy.array(list(iterable)).view(cls)

def __setstate__(self, state):
Expand Down
2 changes: 1 addition & 1 deletion deap/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def addPrimitive(self, primitive, in_types, ret_type, name=None):
"""Add a primitive to the set.
:param primitive: callable object or a function.
:parma in_types: list of primitives arguments' type
:param in_types: list of primitives arguments' type
:param ret_type: type returned by the primitive.
:param name: alternative name for the primitive instead
of its __name__ attribute.
Expand Down
6 changes: 3 additions & 3 deletions deap/tools/crossover.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ def cxTwoPoints(ind1, ind2):

def cxUniform(ind1, ind2, indpb):
"""Executes a uniform crossover that modify in place the two
:term:`sequence` individuals. The attributes are swapped accordingto the
:term:`sequence` individuals. The attributes are swapped according to the
*indpb* probability.
:param ind1: The first individual participating in the crossover.
:param ind2: The second individual participating in the crossover.
:param indpb: Independent probabily for each attribute to be exchanged.
:param indpb: Independent probability for each attribute to be exchanged.
:returns: A tuple of two individuals.
This function uses the :func:`~random.random` function from the python base
Expand Down Expand Up @@ -390,7 +390,7 @@ def cxMessyOnePoint(ind1, ind2):
def cxESBlend(ind1, ind2, alpha):
"""Executes a blend crossover on both, the individual and the strategy. The
individuals shall be a :term:`sequence` and must have a :term:`sequence`
:attr:`strategy` attribute. Adjustement of the minimal strategy shall be done
:attr:`strategy` attribute. Adjustment of the minimal strategy shall be done
after the call to this function, consider using a decorator.
:param ind1: The first evolution strategy participating in the crossover.
Expand Down
2 changes: 1 addition & 1 deletion deap/tools/emo.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def sweepB(best, worst, front):
class selNSGA3WithMemory(object):
"""Class version of NSGA-III selection including memory for best, worst and
extreme points. Registering this operator in a toolbox is a bit different
than classical operators, it requires to instanciate the class instead
than classical operators, it requires to instantiate the class instead
of just registering the function::
>>> from deap import base
Expand Down
4 changes: 2 additions & 2 deletions deap/tools/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ def mutUniformInt(individual, low, up, indpb):
:param individual: :term:`Sequence <sequence>` individual to be mutated.
:param low: The lower bound or a :term:`python:sequence` of
of lower bounds of the range from wich to draw the new
of lower bounds of the range from which to draw the new
integer.
:param up: The upper bound or a :term:`python:sequence` of
of upper bounds of the range from wich to draw the new
of upper bounds of the range from which to draw the new
integer.
:param indpb: Independent probability for each attribute to be mutated.
:returns: A tuple of one individual.
Expand Down
18 changes: 9 additions & 9 deletions deap/tools/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class History(object):
import networkx
graph = networkx.DiGraph(history.genealogy_tree)
graph = graph.reverse() # Make the grah top-down
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()
Expand Down Expand Up @@ -126,7 +126,7 @@ def getGenealogy(self, individual, max_depth=float("inf")):
:func:`~deap.tools.History.update` in order to retrieve its associated
genealogy tree. The returned graph contains the parents up to
*max_depth* variations before this individual. If not provided
the maximum depth is up to the begining of the evolution.
the maximum depth is up to the beginning of the evolution.
:param individual: The individual at the root of the genealogy tree.
:param max_depth: The approximate maximum distance between the root
Expand Down Expand Up @@ -264,7 +264,7 @@ class Logbook(list):
Data can be retrieved via the :meth:`select` method given the appropriate
names.
The :class:`Logbook` class may also contain other logbooks refered to
The :class:`Logbook` class may also contain other logbooks referred to
as chapters. Chapters are used to store information associated to a
specific part of the evolution. For example when computing statistics
on different components of individuals (namely :class:`MultiStatistics`),
Expand All @@ -291,7 +291,7 @@ def __init__(self):
logbook.chapters["size"].select("mean")
Compiling a :class:`MultiStatistics` object returns a dictionary
containing dictionnaries, therefore when recording such an object in a
containing dictionaries, therefore when recording such an object in a
logbook using the keyword argument unpacking operator (**), chapters
will be automatically added to the logbook.
::
Expand Down Expand Up @@ -321,7 +321,7 @@ def __init__(self):
logbook.header = ("gen", "mean", "max")
If not set the header is built with all fields, in arbritrary order
If not set the header is built with all fields, in arbitrary order
on insertion of the first data. The header can be removed by setting
it to :data:`None`.
"""
Expand All @@ -334,7 +334,7 @@ def __init__(self):

def record(self, **infos):
"""Enter a record of event in the logbook as a list of key-value pairs.
The informations are appended chronogically to a list as a dictionary.
The informations are appended chronologically to a list as a dictionary.
When the value part of a pair is a dictionary, the informations contained
in the dictionary are recorded in a chapter entitled as the name of the
key part of the pair. Chapters are also Logbook.
Expand Down Expand Up @@ -519,10 +519,10 @@ def update(self, population):
worst individuals in it by the best individuals present in
*population* (if they are better). The size of the hall of fame is
kept constant.
:param population: A list of individual with a fitness attribute to
update the hall of fame with.
"""
"""
for ind in population:
if len(self) == 0 and self.maxsize !=0:
# Working on an empty hall of fame is problematic for the
Expand Down Expand Up @@ -593,7 +593,7 @@ class ParetoFront(HallOfFame):
that ever lived in the population. That means that the Pareto front hall of
fame can contain an infinity of different individuals.
:param similar: A function that tels the Pareto front whether or not two
:param similar: A function that tells the Pareto front whether or not two
individuals are similar, optional.
The size of the front may become very large if it is used for example on
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/gp_symbreg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ the MSE (Mean Squared Error), which is returned as the fitness of the individual

Afterwards, we register the evaluation function. We also choose the selection
method (a tournament of size 3), the mate method (one point crossover with
uniform probability over all the nodes), the mutation method (an uniform
uniform probability over all the nodes), and the mutation method (a uniform
probability mutation which may append a new full sub-tree to a node).

Then, we decorate the mate and mutate method to limit the height of generated
Expand Down

0 comments on commit d714385

Please sign in to comment.