Skip to content

Commit 37ace30

Browse files
authored
docs: clean up wording in base_operations docs
1 parent e3aa296 commit 37ace30

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/test_base_2.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
# Node and Tree Operations
66
77
This example demonstrates how to create and manipulate expression trees
8-
using the [`Node`](@ref) type. We'll create a tree,
9-
perform various operations, and show how to traverse and modify it.
8+
using the [`Node`](@ref) type.
109
11-
First, let's create a simple expression tree.
12-
We can bootstrap this by creating a node to hold `feature=1`,
13-
indicating the first input variable (first column of data):
10+
First, let's create a node to reference `feature=1` of our dataset:
1411
=#
1512
using DynamicExpressions, Random
1613

@@ -72,12 +69,14 @@
7269
7370
Let's see an example. Say we just want to count the nodes in the tree:
7471
=#
75-
tree_mapreduce(node -> 1, +, tree)
72+
num_nodes = tree_mapreduce(node -> 1, +, tree)
73+
@test num_nodes == 8 #src
7674
#=
7775
Here, the `+` handles both the cases of 1 child and 2 children.
7876
Here, we didn't need to specify a custom branch function, but we could do that too:
7977
=#
80-
tree_mapreduce(leaf_node -> 1, branch_node -> 0, +, tree)
78+
num_leafs = tree_mapreduce(leaf_node -> 1, branch_node -> 0, +, tree)
79+
@test num_leafs == 4 #src
8180
#=
8281
This counts the number of leaf nodes in the tree. For `tree`,
8382
this was `x`, `y`, `const_1`, and `x`.
@@ -93,9 +92,10 @@
9392
As a more complex example, let's compute the depth of a tree. Here, we need
9493
to use a more complicated reduction operation – the `max`:
9594
=#
96-
tree_mapreduce(
95+
depth = tree_mapreduce(
9796
node -> 1, (parent, children...) -> 1 + max(children...), x + sin(sin(exp(x)))
9897
)
98+
@test depth == 5 #src
9999
#=
100100
Here, the `max` handles both the cases of 1 child and 2 children.
101101
The parent node contributes `1` at each depth. Note that the inputs

0 commit comments

Comments
 (0)