Skip to content

Commit dbb2866

Browse files
committed
refactor: rename with_tree to with_content
1 parent 717eb4f commit dbb2866

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/DynamicExpressions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import .NodeModule:
6767
@reexport import .ExtensionInterfaceModule: node_to_symbolic, symbolic_to_node
6868
@reexport import .RandomModule: NodeSampler
6969
@reexport import .ExpressionModule:
70-
AbstractExpression, Expression, with_tree, with_metadata, get_contents, get_metadata
70+
AbstractExpression, Expression, with_contents, with_metadata, get_contents, get_metadata
7171
import .ExpressionModule:
7272
get_tree, get_operators, get_variable_names, Metadata, default_node_type, node_type
7373
@reexport import .ParseModule: @parse_expression, parse_expression

src/Expression.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ end
144144
########################################################
145145

146146
"""
147-
with_tree(ex::AbstractExpression, tree::AbstractExpressionNode)
148-
with_tree(ex::AbstractExpression, tree::AbstractExpression)
147+
with_contents(ex::AbstractExpression, tree::AbstractExpressionNode)
148+
with_contents(ex::AbstractExpression, tree::AbstractExpression)
149149
150150
Create a new expression based on `ex` but with a different `tree`
151151
"""
152-
function with_tree(ex::AbstractExpression, tree::AbstractExpression)
153-
return with_tree(ex, get_contents(tree))
152+
function with_contents(ex::AbstractExpression, tree::AbstractExpression)
153+
return with_contents(ex, get_contents(tree))
154154
end
155-
function with_tree(ex::AbstractExpression, tree)
155+
function with_contents(ex::AbstractExpression, tree)
156156
return constructorof(typeof(ex))(tree, get_metadata(ex))
157157
end
158158
function get_contents(ex::Expression)

src/Interfaces.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ using ..ExpressionModule:
4545
get_variable_names,
4646
get_contents,
4747
get_metadata,
48-
with_tree,
48+
with_contents,
4949
with_metadata,
5050
default_node_type
5151
using ..ParametricExpressionModule: ParametricExpression, ParametricNode
@@ -56,7 +56,7 @@ using ..ParametricExpressionModule: ParametricExpression, ParametricNode
5656

5757
## mandatory
5858
function _check_get_contents(ex::AbstractExpression)
59-
new_ex = with_tree(ex, get_contents(ex))
59+
new_ex = with_contents(ex, get_contents(ex))
6060
return new_ex == ex && new_ex isa typeof(ex)
6161
end
6262
function _check_get_metadata(ex::AbstractExpression)
@@ -78,9 +78,9 @@ function _check_copy(ex::AbstractExpression)
7878
# TODO: Could include checks for aliasing here
7979
return preserves
8080
end
81-
function _check_with_tree(ex::AbstractExpression)
82-
new_ex = with_tree(ex, get_contents(ex))
83-
new_ex2 = with_tree(ex, ex)
81+
function _check_with_contents(ex::AbstractExpression)
82+
new_ex = with_contents(ex, get_contents(ex))
83+
new_ex2 = with_contents(ex, ex)
8484
return new_ex == ex && new_ex isa typeof(ex) && new_ex2 == ex && new_ex2 isa typeof(ex)
8585
end
8686
function _check_with_metadata(ex::AbstractExpression)
@@ -142,7 +142,7 @@ ei_components = (
142142
get_operators = "returns the operators used in the expression (or pass `operators` explicitly to override)" => _check_get_operators,
143143
get_variable_names = "returns the variable names used in the expression (or pass `variable_names` explicitly to override)" => _check_get_variable_names,
144144
copy = "returns a copy of the expression" => _check_copy,
145-
with_tree = "returns the expression with different tree" => _check_with_tree,
145+
with_contents = "returns the expression with different tree" => _check_with_contents,
146146
with_metadata = "returns the expression with different metadata" => _check_with_metadata,
147147
),
148148
optional = (

test/test_expressions.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ end
168168
@test has_constants(ex) == false
169169
end
170170

171-
@testitem "Expression with_tree" begin
171+
@testitem "Expression with_contents" begin
172172
using DynamicExpressions
173173

174174
ex = @parse_expression(x1 + 1.5, binary_operators = [+, *], variable_names = ["x1"])
175175
ex2 = @parse_expression(x1 + 3.0, binary_operators = [+], variable_names = ["x1"])
176176

177-
t2 = DynamicExpressions.get_tree(ex2)
178-
ex_modified = DynamicExpressions.with_tree(ex, t2)
177+
t2 = DynamicExpressions.get_contents(ex2)
178+
ex_modified = DynamicExpressions.with_contents(ex, t2)
179179
@test DynamicExpressions.get_tree(ex_modified) == t2
180180
end
181181

0 commit comments

Comments
 (0)