Skip to content

Commit 4180759

Browse files
committed
Type stability in equation utilities
1 parent 07f434b commit 4180759

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/OperatorEnumConstruction.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ function (tree::AbstractExpressionNode)(X; kws...)
4848
:AbstractExpressionNode,
4949
)
5050
latest_operators_type = LATEST_OPERATORS_TYPE.x
51-
if latest_operators_type == IsNothing
51+
52+
latest_operators_type == IsNothing &&
5253
error("Please use the `tree(X, operators; kws...)` syntax instead.")
53-
elseif latest_operators_type == IsOperatorEnum
54+
55+
if latest_operators_type == IsOperatorEnum
5456
latest_operators = LATEST_OPERATORS.x::OperatorEnum
5557
return tree(X, latest_operators; kws...)
5658
else
@@ -66,14 +68,13 @@ function _grad_evaluator(tree::AbstractExpressionNode, X; kws...)
6668
)
6769
latest_operators_type = LATEST_OPERATORS_TYPE.x
6870
# return _grad_evaluator(tree, X, $operators; kws...)
69-
if latest_operators_type == IsNothing
71+
latest_operators_type == IsNothing &&
7072
error("Please use the `tree'(X, operators; kws...)` syntax instead.")
71-
elseif latest_operators_type == IsOperatorEnum
72-
latest_operators = LATEST_OPERATORS.x::OperatorEnum
73-
return _grad_evaluator(tree, X, latest_operators; kws...)
74-
else
73+
latest_operators_type == IsGenericOperatorEnum &&
7574
error("Gradients are not implemented for `GenericOperatorEnum`.")
76-
end
75+
76+
latest_operators = LATEST_OPERATORS.x::OperatorEnum
77+
return _grad_evaluator(tree, X, latest_operators; kws...)
7778
end
7879

7980
function set_default_variable_names!(variable_names::Vector{String})
@@ -194,11 +195,10 @@ function _extend_operators(operators, skip_user_operators, kws, __module__::Modu
194195
if length(kws) == 1 && :empty_old_operators in map(x -> x.args[1], kws)
195196
@assert kws[1].head == :(=)
196197
kws[1].args[2]
197-
elseif length(kws) > 0
198-
error(
198+
else
199+
length(kws) > 0 && error(
199200
"You passed the keywords $(kws), but only `empty_old_operators` is supported.",
200201
)
201-
else
202202
true
203203
end
204204
@gensym f skip type_requirements build_converters binary_exists unary_exists

0 commit comments

Comments
 (0)