|
7 | 7 | using DynamicExpressions |
8 | 8 | using DynamicExpressions: |
9 | 9 | string_tree, parse_expression, eval_tree_array, Node, get_operators, get_tree |
| 10 | + using LoopVectorization: LoopVectorization |
| 11 | + using Bumper: Bumper |
10 | 12 |
|
11 | 13 | # bring the generator into scope |
12 | 14 | include("supposition_utils.jl") |
|
20 | 22 | T; num_features=n_features, max_layers=max_layers, operators=operators |
21 | 23 | ) |
22 | 24 |
|
23 | | - @check function roundtrip_string(ex=expr_gen) |
| 25 | + result = @check function roundtrip_string(ex=expr_gen) |
24 | 26 | tree_str = string_tree(ex) |
25 | 27 | ex_parsed = parse_expression( |
26 | 28 | Meta.parse(tree_str); |
|
30 | 32 | ) |
31 | 33 | return ex == ex_parsed |
32 | 34 | end |
| 35 | + @test something(result.result) isa Supposition.Pass |
33 | 36 |
|
34 | 37 | input_gen = make_input_matrix_generator(T; n_features) |
35 | | - @check max_examples = 1024 function eval_against_string(ex=expr_gen, X=input_gen) |
36 | | - expression_result, ok = eval_tree_array(ex, X) |
37 | | - !ok && return true # If the expression is not valid, we can't test it |
| 38 | + args_gen = map( |
| 39 | + (ex, X, turbo, bumper) -> (; ex, X, turbo, bumper), |
| 40 | + expr_gen, |
| 41 | + input_gen, |
| 42 | + Data.Booleans(), |
| 43 | + Data.Booleans(), |
| 44 | + ) |
| 45 | + # We only consider expressions that don't have NaN/Inf/etc. |
| 46 | + clean_args_gen = filter(args -> eval_tree_array(args.ex, args.X)[2], args_gen) |
| 47 | + result2 = @check max_examples = 1000 function eval_against_string(args=clean_args_gen) |
| 48 | + (; ex, X, turbo, bumper) = args |
| 49 | + expression_result, ok = eval_tree_array(ex, X; turbo, bumper) |
38 | 50 | tree_str = string_tree(ex) |
39 | | - f_sym = gensym("f") |
40 | 51 | f = eval(Meta.parse("(x1, x2, x3, x4, x5) -> ($tree_str)")) |
41 | 52 | true_result = Float64[Base.invokelatest(f, x...) for x in eachcol(X)] |
42 | | - return expression_result ≈ true_result |
| 53 | + return ok && expression_result ≈ true_result |
43 | 54 | end |
| 55 | + @test something(result2.result) isa Supposition.Pass |
44 | 56 | end |
0 commit comments