Skip to content

Commit a49ed2a

Browse files
committed
also use expression to pick default ruleset
1 parent b350b61 commit a49ed2a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/simplify.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
##### Numeric simplification
22

33
"""
4-
default_rules(context::T)::RuleSet
4+
default_rules(expr, context::T)::RuleSet
55
6-
The `RuleSet` to be used by default for a given context. Julia packages
7-
defining their own context types should define this method.
6+
The `RuleSet` to be used by default for a given expression and the context.
7+
Julia packages defining their own context types should define this method.
88
9-
By default, returns SIMPLIFY_RULES
9+
By default SymbolicUtils will try to apply appropriate rules for expressions
10+
of symtype Number.
1011
"""
11-
default_rules(::Any) = SIMPLIFY_RULES
12+
default_rules(x, ctx) = SIMPLIFY_RULES
1213

1314
"""
1415
simplify(x, ctx=EmptyCtx();
15-
rules=default_rules(ctx),
16+
rules=default_rules(x, ctx),
1617
fixpoint=true,
1718
applyall=true,
1819
recurse=true)
@@ -32,7 +33,7 @@ Applies them once if `fixpoint=false`.
3233
The `applyall` and `recurse` keywords are forwarded to the enclosed
3334
`RuleSet`, they are mainly used for internal optimization.
3435
"""
35-
function simplify(x, ctx=EmptyCtx(); rules=default_rules(ctx), fixpoint=true, applyall=true, recurse=true)
36+
function simplify(x, ctx=EmptyCtx(); rules=default_rules(x, ctx), fixpoint=true, applyall=true, recurse=true)
3637
if fixpoint
3738
SymbolicUtils.fixpoint(rules, x, ctx; recurse=recurse, applyall=recurse)
3839
else

0 commit comments

Comments
 (0)