Skip to content

Commit a5259ad

Browse files
Fix CI on Julia 1 + SymbolicUtils v4 + JET
1 parent d4b12df commit a5259ad

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

test/runtests.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,25 @@ if "jet" in test_name
2626
struct MyIgnoredModule
2727
mod::Module
2828
end
29-
function JET.match_module(
30-
mod::MyIgnoredModule, @nospecialize(report::JET.InferenceErrorReport)
31-
)
32-
s_mod = string(mod.mod)
33-
any(report.vst) do vst
34-
occursin(s_mod, string(JET.linfomod(vst.linfo)))
29+
if isdefined(JET, :match_module)
30+
function JET.match_module(
31+
mod::MyIgnoredModule, @nospecialize(report::JET.InferenceErrorReport)
32+
)
33+
s_mod = string(mod.mod)
34+
any(report.vst) do vst
35+
occursin(s_mod, string(JET.linfomod(vst.linfo)))
36+
end
3537
end
3638
end
39+
3740
JET.test_package(
3841
DynamicExpressions;
3942
target_defined_modules=true,
4043
ignored_modules=(
4144
MyIgnoredModule(DynamicExpressions.NonDifferentiableDeclarationsModule),
4245
),
4346
)
44-
# TODO: Hack to get JET to ignore modules
45-
# https://github.com/aviatesk/JET.jl/issues/570#issuecomment-2199167755
47+
# Extend only when available (varies by JET version).
4648
end
4749
end
4850
if "main" in test_name

test/test_chainrules.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ let
8383
end
8484

8585
# Operator that is NaN for forward pass
86-
bad_op(x) = x > 0.0 ? log(x) : convert(typeof(x), NaN)
86+
# Define only for numeric types; `@extend_operators` adds the `Node` method.
87+
bad_op(x::Real) = x > 0.0 ? log(x) : convert(typeof(x), NaN)
8788
# And operator that is undefined for backward pass
88-
undefined_grad_op(x) = x >= 0.0 ? x : zero(x)
89+
undefined_grad_op(x::Real) = x >= 0.0 ? x : zero(x)
8990
# And operator that gives a NaN for backward pass
9091
bad_grad_op(x) = x
9192

test/test_symbolic_utils.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,7 @@ let
5757
# Test round trip preserves structure and variable names
5858
operators = OperatorEnum(; unary_operators=(sin,), binary_operators=(+, *, -, /))
5959
ex2_again = convert(Expression, eqn2, operators; variable_names=["alpha", "beta"])
60-
@test ex2 == ex2_again
60+
61+
# SymbolicUtils may reorder commutative `+`; check semantic equality.
62+
@test convert(SymbolicUtils.Symbolic, ex2_again) == eqn2
6163
end

0 commit comments

Comments
 (0)