Skip to content

Commit 3ece18f

Browse files
committed
improved simplify function to fix CI
1 parent e37b4b4 commit 3ece18f

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

src/simplify_rules.jl

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ let
5353

5454
POW_RULES = [
5555
@rule(^(~x::_isone, ~z) => 1)
56+
@rule(ℯ^(~x) => exp(~x))
57+
@rule((~x)^(1//2) => sqrt(~x))
5658
]
5759

5860
ASSORTED_RULES = [
@@ -132,17 +134,15 @@ let
132134
]
133135

134136
function number_simplifier()
135-
rule_tree = [If(iscall, Chain(ASSORTED_RULES)),
136-
If(x -> !isadd(x) && is_operation(+)(x),
137-
Chain(CANONICALIZE_PLUS)),
138-
If(is_operation(+), Chain(PLUS_DISTRIBUTE)), # This would be useful even if isadd
139-
If(x -> !ismul(x) && is_operation(*)(x),
140-
Chain(CANONICALIZE_TIMES)),
141-
If(is_operation(*), MUL_DISTRIBUTE),
142-
If(x -> !ispow(x) && is_operation(^)(x),
143-
Chain(CANONICALIZE_POW)),
144-
If(is_operation(^), Chain(POW_RULES)),
145-
] |> RestartedChain
137+
rule_tree = [
138+
If(iscall, Chain(ASSORTED_RULES)),
139+
If(x -> !isadd(x) && is_operation(+)(x), Chain(CANONICALIZE_PLUS)),
140+
If(is_operation(+), Chain(PLUS_DISTRIBUTE)), # This would be useful even if isadd
141+
If(x -> !ismul(x) && is_operation(*)(x), Chain(CANONICALIZE_TIMES)),
142+
If(is_operation(*), MUL_DISTRIBUTE),
143+
If(x -> !ispow(x) && is_operation(^)(x), Chain(CANONICALIZE_POW)),
144+
If(is_operation(^), Chain(POW_RULES)),
145+
] |> RestartedChain
146146

147147
rule_tree
148148
end
@@ -159,17 +159,19 @@ let
159159

160160
function default_simplifier(; kw...)
161161
IfElse(has_trig_exp,
162-
Postwalk(IfElse(x->symtype(x) <: Number,
163-
Chain((number_simplifier(),
164-
trig_exp_simplifier())),
165-
If(x->symtype(x) <: Bool,
166-
bool_simplifier()))
167-
; kw...),
168-
Postwalk(Chain((If(x->symtype(x) <: Number,
169-
number_simplifier()),
170-
If(x->symtype(x) <: Bool,
171-
bool_simplifier())))
172-
; kw...))
162+
Postwalk(
163+
IfElse(x->symtype(x) <: Number,
164+
Chain((number_simplifier(), trig_exp_simplifier())),
165+
If(x->symtype(x) <: Bool, bool_simplifier())
166+
); kw...
167+
),
168+
Postwalk(
169+
Chain((
170+
If(x->symtype(x) <: Number, number_simplifier()),
171+
If(x->symtype(x) <: Bool, bool_simplifier())
172+
)); kw...
173+
)
174+
)
173175
end
174176

175177
# reduce overhead of simplify by defining these as constant

0 commit comments

Comments
 (0)