-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
Hi, I encountered the following problem:
using TypedPolynomials, SymPy
@polyvar x
@syms a
differentiate(a*x^0-a,x)gives a
ERROR: MethodError: no method matching zero(::Type{Any})
Closest candidates are:
zero(::Type{Union{Missing, T}}) where T at missing.jl:105
zero(::Type{Missing}) at missing.jl:103
zero(::Type{LibGit2.GitHash}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/LibGit2/src/oid.jl:220
...
Stacktrace:
[1] zero(::Type{Any}) at ./missing.jl:105
[2] reduce_empty(::typeof(+), ::Type{T} where T) at ./reduce.jl:306
[3] reduce_empty(::typeof(Base.add_sum), ::Type{T} where T) at ./reduce.jl:313
[4] mapreduce_empty(::typeof(identity), ::Function, ::Type{T} where T) at ./reduce.jl:335
[5] _mapreduce(::typeof(identity), ::typeof(Base.add_sum), ::IndexLinear, ::Array{Any,1}) at ./reduce.jl:392
[6] _mapreduce_dim at ./reducedim.jl:312 [inlined]
[7] #mapreduce#580 at ./reducedim.jl:307 [inlined]
[8] mapreduce at ./reducedim.jl:307 [inlined]
[9] _sum at ./reducedim.jl:657 [inlined]
[10] _sum at ./reducedim.jl:656 [inlined]
[11] #sum#583 at ./reducedim.jl:652 [inlined]
[12] sum at ./reducedim.jl:652 [inlined]
[13] polynomial!(::Array{Any,1}, ::MultivariatePolynomials.SortedState) at /Users/gerickf/.julia/packages/MultivariatePolynomials/fixWm/src/polynomial.jl:64
[14] differentiate(::Polynomial{Sym,Term{Sym,Monomial{(x,),1}},Array{Term{Sym,Monomial{(x,),1}},1}}, ::Variable{:x}) at /Users/gerickf/.julia/packages/MultivariatePolynomials/fixWm/src/differentiation.jl:40
[15] top-level scope at REPL[8]:1
I'm using julia v1.4.0 with the masters of TypedPolynomials.jl and MultivariatePolynomials.jl.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
blegat commentedon May 29, 2020
I can reproduce it. The issue is that the polynomial has no terms, (you can check it with
iszeroornterms, it's cheap) so it has troubles inferring the type of the differentiation of a term.fgerick commentedon May 30, 2020
I assumed that it must be due to no terms in the polynomial. It came a bit of a surprise, because
typeof(a*x^0-a)givesPolynomial{Sym,Term{Sym,Monomial{(x,),1}},Array{Term{Sym,Monomial{(x,),1}},1}}, a very clearly defined type!fgerick commentedon Sep 22, 2020
is there anything that keeps #144 from being merged?