Skip to content

Commit fb7c5a4

Browse files
committed
Add evaluation test for custom operators
1 parent e003201 commit fb7c5a4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/test_tree_construction.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ end
117117
function op3(x)
118118
return sin(x) + cos(x)
119119
end
120+
local operators, tree
120121
operators = OperatorEnum(;
121122
default_params..., binary_operators=(op1, op2), unary_operators=(op3,)
122123
)
@@ -125,3 +126,6 @@ x1 = Node(; feature=1)
125126
x2 = Node(; feature=2)
126127
tree = op1(op2(x1, x2), op3(x1))
127128
@test repr(tree) == "op1(op2(x1, x2), op3(x1))"
129+
# Test evaluation:
130+
X = randn(MersenneTwister(0), 2, 10);
131+
@test tree(X) ((x1, x2) -> op1(op2(x1, x2), op3(x1))).(X[1, :], X[2, :])

0 commit comments

Comments
 (0)