@@ -395,8 +395,8 @@ We'll consider postorder traversal first, as it's the easier to implement.
395395 tree: TreeNode
396396 The tree to be visited.
397397 fn: function(node, *fn_children)
398- A function to be applied at each node. The function should take the
399- node to be visited as its first argument, and the results of
398+ A function to be applied at each node. The function should take
399+ the node to be visited as its first argument, and the results of
400400 visiting its children as any further arguments.
401401 """
402402 return fn(tree, *(postvisitor(c, fn) for c in tree.children))
@@ -480,8 +480,8 @@ call :func:`previsitor` on the child nodes.
480480 tree: TreeNode
481481 The tree to be visited.
482482 fn: function(node, fn_parent)
483- A function to be applied at each node. The function should take the
484- node to be visited as its first argument, and the result of
483+ A function to be applied at each node. The function should take
484+ the node to be visited as its first argument, and the result of
485485 visiting its parent as the second.
486486 """
487487 fn_out = fn(tree, fn_parent)
@@ -776,7 +776,8 @@ function.
776776 Any keyword arguments required to evaluate specific types of
777777 expression.
778778 symbol_map: dict
779- A dictionary mapping Symbol names to numerical values, for example:
779+ A dictionary mapping Symbol names to numerical values, for
780+ example:
780781
781782 {'x': 1}
782783 """
@@ -819,24 +820,24 @@ function.
819820 return o[0] ** o[1]
820821
821822 Next we turn our attention to the implementation of evaluation for the different
822- expression types. Look first at lines 27-29 , which provide the evaluation of
823+ expression types. Look first at lines 28-30 , which provide the evaluation of
823824:class: `Number ` nodes. The function body is trivial: the evaluation of a
824825:class: `Number ` is simply its value. The function interface is more interesting.
825826Notice that the function name is given as `_ `. This is the Python convention for
826827a name which will never be used. This function will never be called by its
827- declared name. Instead, look at the decorator on line 27 . The single dispatch
828+ declared name. Instead, look at the decorator on line 28 . The single dispatch
828829function :func: `~example_code.expression_tools.evaluate ` has a :term: `method `
829830:meth: `register `. When used as a decorator, the :meth: `register ` method of a
830831single dispatch function registers the function that follows as implementation
831832for the :keyword: `class ` given as an argument to :meth: `register `. On this
832833occasion, this is :class: `expressions.Number `.
833834
834- Now look at lines 32-34 . These contain the implementation of
835+ Now look at lines 33-35 . These contain the implementation of
835836:func: `~example_code.expression_tools.evaluate ` for :class: `expressions.Symbol `.
836837In order to evaluate a symbol, we depend on the mapping from symbol names to
837838numerical values that has been passed in.
838839
839- Finally, look at lines 37-39 . These define the evaluation visitor for addition.
840+ Finally, look at lines 38-40 . These define the evaluation visitor for addition.
840841This works simply by adding the results of evaluating the two operands of
841842:class: `expressions.Add `. The evaluation visitors for the other operators
842843follow in an analogous manner.
@@ -869,8 +870,8 @@ function.
869870 expr: Expression
870871 The expression to be visited.
871872 fn: function(node, *o, **kwargs)
872- A function to be applied at each node. The function should take the
873- node to be visited as its first argument, and the results of
873+ A function to be applied at each node. The function should take
874+ the node to be visited as its first argument, and the results of
874875 visiting its operands as any further positional arguments. Any
875876 additional information that the visitor requires can be passed in
876877 as keyword arguments.
0 commit comments