Skip to content

Commit f643b88

Browse files
committed
make it work even if promote_symtype is not defined
1 parent 2fdca11 commit f643b88

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/polyform.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,12 @@ Expand expressions by distributing multiplication over addition, e.g.,
229229
multivariate polynomials implementation.
230230
`variable_type` can be any subtype of `MultivariatePolynomials.AbstractVariable`.
231231
"""
232-
expand(expr) = Postwalk(identity)(PolyForm(expr, Fs=Union{typeof(+), typeof(*), typeof(^)}, recurse=true))
232+
expand(expr) = unpolyize(PolyForm(expr, Fs=Union{typeof(+), typeof(*), typeof(^)}, recurse=true))
233233

234+
function unpolyize(x)
235+
simterm(x, f, args; kw...) = similarterm(x, f, args, symtype(x); kw...)
236+
Postwalk(identity, similarterm=simterm)(x)
237+
end
234238

235239
## Rational Polynomial form with Div
236240

@@ -284,7 +288,7 @@ function simplify_fractions(x; polyform=false)
284288

285289
expr = Postwalk(sdiv quick_cancel)(Postwalk(add_with_div)(x))
286290

287-
polyform ? expr : Postwalk(identity)(expr)
291+
polyform ? expr : unpolyize(expr)
288292
end
289293

290294
function add_with_div(x, flatten=true)

0 commit comments

Comments
 (0)