9494 Node (1 , Node (1 , Node (; val= 0.1 ), Node (; val= 0.2 )) + Node (; val= 0.2 )) +
9595 Node (; val= 2.0 )
9696 @test repr (tree) ≈ " (cos((0.1 + 0.2) + 0.2) + 2.0)"
97- @test repr (combine_operators (tree, operators)) ≈ " (cos(0.4 + 0.1) + 2.0)"
97+ @test repr (combine_operators! (tree, operators)) ≈ " (cos(0.4 + 0.1) + 2.0)"
9898end
9999
100100@testitem " Basic operator simplifications" begin
101101 using DynamicExpressions, Test
102- import DynamicExpressions. SimplifyModule: combine_operators
102+ import DynamicExpressions. SimplifyModule: combine_operators!
103103
104104 operators = OperatorEnum (; binary_operators= (+ , - , * , / ), unary_operators= (cos, sin))
105105 x = Node (; feature= 1 )
@@ -110,52 +110,52 @@ end
110110
111111 # multiplication by 0
112112 tree = zero_node * x
113- @test combine_operators (tree, operators) == zero_node
113+ @test combine_operators! (tree, operators) == zero_node
114114 tree = x * zero_node
115- @test combine_operators (tree, operators) == zero_node
115+ @test combine_operators! (tree, operators) == zero_node
116116
117117 # multiplication by 1
118118 tree = one_node * x
119- @test combine_operators (tree, operators) == x
119+ @test combine_operators! (tree, operators) == x
120120 tree = x * one_node
121- @test combine_operators (tree, operators) == x
121+ @test combine_operators! (tree, operators) == x
122122
123123 # addition by 0
124124 tree = zero_node + x
125- @test combine_operators (tree, operators) == x
125+ @test combine_operators! (tree, operators) == x
126126 tree = x + zero_node
127- @test combine_operators (tree, operators) == x
127+ @test combine_operators! (tree, operators) == x
128128
129129 # division by self -> 1
130130 tree = x / x
131- @test combine_operators (tree, operators). val == 1.0
131+ @test combine_operators! (tree, operators). val == 1.0
132132
133133 # nested multiplication by constants
134134 tree1 = (two_node * x) * three_node
135135 tree2 = Node (; val= 6.0 ) * x
136- @test combine_operators (tree1, operators) == combine_operators (tree2, operators)
136+ @test combine_operators! (tree1, operators) == combine_operators! (tree2, operators)
137137end
138138
139139@testitem " Constant combination" begin
140140 using DynamicExpressions, Test
141- import DynamicExpressions. SimplifyModule: combine_operators
141+ import DynamicExpressions. SimplifyModule: combine_operators!
142142
143143 operators = OperatorEnum (; binary_operators= (+ , - , * , / ), unary_operators= (cos, sin))
144144 x1 = Node (; feature= 1 )
145145
146146 # Test commutative constant combination
147147 tree = Node (; val= 0.5 ) + (Node (; val= 0.2 ) + x1)
148- @test combine_operators (tree, operators) == x1 + Node (; val= 0.7 )
148+ @test combine_operators! (tree, operators) == x1 + Node (; val= 0.7 )
149149
150150 # Test nested multiplication by constants
151151 tree = (Node (; val= 2.0 ) * x1) * Node (; val= 3.0 )
152- @test combine_operators (tree, operators) == x1 * Node (; val= 6.0 )
152+ @test combine_operators! (tree, operators) == x1 * Node (; val= 6.0 )
153153
154154 # Test nested addition by constants
155155 tree = (Node (; val= 2.0 ) + x1) + Node (; val= 3.0 )
156- @test combine_operators (tree, operators) == x1 + Node (; val= 5.0 )
156+ @test combine_operators! (tree, operators) == x1 + Node (; val= 5.0 )
157157
158158 # Test mixed operations don't combine incorrectly
159159 tree = (Node (; val= 2.0 ) * x1) + Node (; val= 3.0 )
160- @test combine_operators (tree, operators) == tree
160+ @test combine_operators! (tree, operators) == tree
161161end
0 commit comments