@@ -7,23 +7,31 @@ const FakeCuArray = ext.FakeCuArray
7
7
8
8
include (" tree_gen_utils.jl" )
9
9
10
+ safe_sin (x) = isfinite (x) ? sin (x) : convert (eltype (x), NaN )
11
+ safe_cos (x) = isfinite (x) ? cos (x) : convert (eltype (x), NaN )
12
+
10
13
let
11
- operators = OperatorEnum (; binary_operators= [+ , - , * , / ], unary_operators= [cos, sin]);
14
+ operators = OperatorEnum (;
15
+ binary_operators= [+ , - , * , / ], unary_operators= [safe_sin, safe_cos]
16
+ )
12
17
x1, x2, x3 = (i -> Node (Float64; feature= i)). (1 : 3 )
13
18
14
19
for T in (Float32, Float64, ComplexF64), num_trees in (1 , 2 , 3 ), seed in 0 : 10
15
20
Random. seed! (seed)
16
21
num_rows = rand (10 : 30 )
17
22
nodes_per = rand (10 : 25 , num_trees)
18
- trees = ntuple (i -> gen_random_tree_fixed_size (nodes_per[i], operators, 3 , T), num_trees)
19
- @show trees
23
+ trees = ntuple (
24
+ i -> gen_random_tree_fixed_size (nodes_per[i], operators, 3 , T), num_trees
25
+ )
20
26
X = randn (T, 3 , num_rows)
21
27
y, completed = eval_tree_array (trees, X, operators)
22
28
gpu_y, gpu_completed = eval_tree_array (trees, FakeCuArray (X), operators)
23
29
gpu_y = Array .(gpu_y)
24
30
25
31
for i in eachindex (completed, gpu_completed)
26
- @test ((completed[i] && gpu_completed[i]) && (y[i] ≈ gpu_y[i])) || (! completed[i] && ! gpu_completed[i])
32
+ if completed[i]
33
+ @test y[i] ≈ gpu_y[i]
34
+ end
27
35
end
28
36
end
29
37
end
0 commit comments