@@ -2,13 +2,20 @@ using DynamicExpressions
22using Test
33
44# Test that we generate errors:
5+ baseT = Float64
6+ T = Union{baseT,Vector{baseT},Matrix{baseT}}
7+
58scalar_add (x:: T , y:: T ) where {T<: Real } = x + y
9+
610operators = GenericOperatorEnum (; binary_operators= [scalar_add], extend_user_operators= true )
7- tree = scalar_add (x1, x2)
11+
12+ x1, x2, x3 = [Node (T; feature= i) for i in 1 : 3 ]
13+
14+ tree = Node (1 , x1, x2)
815
916# With error handling:
1017try
11- eval_tree_array (tree, [[1.0 , 2.0 , 3.0 ], [4.0 , 5.0 , 6.0 ]], operators; catch_errors = true )
18+ eval_tree_array (tree, [[1.0 , 2.0 , 3.0 ], [4.0 , 5.0 , 6.0 ]], operators; throw_errors = true )
1219 @test false
1320catch e
1421 @test isa (e, ErrorException)
1825
1926# Without error handling:
2027output, flag = eval_tree_array (
21- tree, [[1.0 , 2.0 , 3.0 ], [4.0 , 5.0 , 6.0 ]], operators; catch_errors = false
28+ tree, [[1.0 , 2.0 , 3.0 ], [4.0 , 5.0 , 6.0 ]], operators; throw_errors = false
2229)
2330@test output === nothing
2431@test ! flag
@@ -32,4 +39,4 @@ catch e
3239end
3340
3441# But can be overrided:
35- output = tree ([[1.0 , 2.0 , 3.0 ], [4.0 , 5.0 , 6.0 ]]; catch_errors = false )
42+ output = tree ([[1.0 , 2.0 , 3.0 ], [4.0 , 5.0 , 6.0 ]]; throw_errors = false )
0 commit comments