Skip to content

Commit cc061f8

Browse files
committed
fix lts JET fail
1 parent c63df32 commit cc061f8

2 files changed

Lines changed: 28 additions & 16 deletions

File tree

src/QuestBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ using SymbolicUtils:
88
SymbolicUtils,
99
Postwalk,
1010
BasicSymbolic,
11+
unwrap,
1112
isterm,
1213
ispow,
1314
isadd,
@@ -19,7 +20,6 @@ using SymbolicUtils:
1920
using Symbolics:
2021
Symbolics,
2122
Num,
22-
unwrap,
2323
wrap,
2424
get_variables,
2525
Equation,

src/Symbolics/fourier.jl

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,23 @@ const _rw_trig_expand = SymbolicUtils.Rewriters.Fixpoint(
5656

5757
function _trig_expand_products(x::BasicSymbolic)
5858
# Expand trig products/powers into sums so `get_independent` can isolate constants.
59-
y = Postwalk(ex -> begin
60-
if ismul(ex)
61-
# In SymbolicUtils v4, `arguments(ismul(...))` includes the numeric coefficient
62-
# even though `ex.coeff` also stores it. Avoid double-counting it.
63-
coeff = ex.coeff
64-
factors = BasicSymbolic[
65-
f for f in arguments(ex) if !(SymbolicUtils.unwrap_const(f) isa Number)
66-
]
67-
rest = isempty(factors) ? 1 : prod(factors; init=1)
68-
return coeff * _rw_trig_expand(rest)
69-
end
70-
return _rw_trig_expand(ex)
71-
end)(x)
59+
y = Postwalk(
60+
ex -> begin
61+
if ismul(ex)
62+
# In SymbolicUtils v4, `arguments(ismul(...))` includes the numeric coefficient
63+
# even though `ex.coeff` also stores it. Avoid double-counting it.
64+
coeff = ex.coeff
65+
factors = BasicSymbolic[
66+
f for f in arguments(ex) if !(SymbolicUtils.unwrap_const(f) isa Number)
67+
]
68+
rest = isempty(factors) ? 1 : prod(factors; init=1)
69+
return coeff * _rw_trig_expand(rest)
70+
end
71+
return _rw_trig_expand(ex)
72+
end,
73+
)(
74+
x
75+
)
7276
return SymbolicUtils.expand(y)
7377
end
7478
_trig_expand_products(x::Num) = wrap(_trig_expand_products(unwrap(x)))
@@ -401,13 +405,21 @@ function _normalize_trig_signs(x::BasicSymbolic)
401405
arg = first(arguments(x))
402406
if SymbolicUtils.isnegative(arg)
403407
new_arg = -arg
404-
return op === sin ? -sin(new_arg) : cos(new_arg)
408+
return if op === sin
409+
-SymbolicUtils.term(sin, new_arg)
410+
else
411+
SymbolicUtils.term(cos, new_arg)
412+
end
405413
elseif ismul(arg)
406414
coeff_val = SymbolicUtils.unwrap_const(arg.coeff)
407415
# Handle coefficients that are complex with zero imaginary part, e.g. (-2 + 0im)θ.
408416
if coeff_val isa Number && isreal(coeff_val) && real(coeff_val) < 0
409417
new_arg = -arg
410-
return op === sin ? -sin(new_arg) : cos(new_arg)
418+
return if op === sin
419+
-SymbolicUtils.term(sin, new_arg)
420+
else
421+
SymbolicUtils.term(cos, new_arg)
422+
end
411423
end
412424
end
413425
end

0 commit comments

Comments
 (0)