@@ -28,14 +28,14 @@ PolyForm(sin((x+y)^2), recurse=true) #=> sin((x^2 + (2x)y + y^2))
2828"""
2929struct PolyForm{T, M} <: Symbolic{T}
3030 p:: MP.AbstractPolynomialLike
31- pvar2sym:: Bijection{Any,Sym } # @polyvar x --> @sym x etc.
31+ pvar2sym:: Bijection{Any,Any } # @polyvar x --> @sym x etc.
3232 sym2term:: Dict{Sym,Any} # Symbol("sin-$hash(sin(x+y))") --> sin(x+y) => sin(PolyForm(...))
3333 metadata:: M
3434end
3535
3636function (:: Type{PolyForm{T}} )(p, d1, d2, m= nothing ) where {T}
3737 p isa Number && return p
38- MP. isconstant (p) && return convert (Number, p)
38+ p isa MP . AbstractPolynomialLike && MP. isconstant (p) && return convert (Number, p)
3939 PolyForm {T, typeof(m)} (p, d1, d2, m)
4040end
4141
@@ -51,7 +51,7 @@ clear_dicts() = (PVAR2SYM[] = WeakRef(nothing); SYM2TERM[] = WeakRef(nothing); n
5151function get_pvar2sym ()
5252 v = PVAR2SYM[]. value
5353 if v === nothing
54- d = Bijection {Any,Sym } ()
54+ d = Bijection {Any,Any } ()
5555 PVAR2SYM[] = WeakRef (d)
5656 return d
5757 else
9393_isone (p:: PolyForm ) = isone (p. p)
9494
9595function polyize (x, pvar2sym, sym2term, vtype, pow, Fs, recurse)
96- if istree (x)
96+ if x isa Number
97+ return x
98+ elseif istree (x)
9799 if ! (symtype (x) <: Number )
98100 error (" Cannot convert $x of symtype $(symtype (x)) into a PolyForm" )
99101 end
@@ -139,9 +141,7 @@ function polyize(x, pvar2sym, sym2term, vtype, pow, Fs, recurse)
139141
140142 return local_polyize (sym)
141143 end
142- elseif x isa Number
143- return x
144- elseif x isa Sym
144+ elseif issym (x)
145145 if haskey (active_inv (pvar2sym), x)
146146 return pvar2sym (x)
147147 end
@@ -151,7 +151,7 @@ function polyize(x, pvar2sym, sym2term, vtype, pow, Fs, recurse)
151151 end
152152end
153153
154- function PolyForm (x:: Symbolic{<:Number} ,
154+ function PolyForm (x,
155155 pvar2sym= get_pvar2sym (),
156156 sym2term= get_sym2term (),
157157 vtype= DynamicPolynomials. PolyVar{true };
@@ -164,8 +164,6 @@ function PolyForm(x::Symbolic{<:Number},
164164 PolyForm {symtype(x)} (p, pvar2sym, sym2term, metadata)
165165end
166166
167- PolyForm (x, args... ;kw... ) = x
168-
169167TermInterface. istree (x:: Type{PolyForm} ) = true
170168
171169TermInterface. operation (x:: PolyForm ) = MP. nterms (x. p) == 1 ? (* ) : (+ )
0 commit comments