Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type instability SymPy Sym #143

Open
fgerick opened this issue May 29, 2020 · 3 comments · May be fixed by #144
Open

Type instability SymPy Sym #143

fgerick opened this issue May 29, 2020 · 3 comments · May be fixed by #144
Assignees

Comments

@fgerick
Copy link

fgerick commented May 29, 2020

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.

@blegat
Copy link
Member

blegat commented May 29, 2020

I can reproduce it. The issue is that the polynomial has no terms, (you can check it with iszero or nterms, it's cheap) so it has troubles inferring the type of the differentiation of a term.

@blegat blegat self-assigned this May 29, 2020
@blegat blegat transferred this issue from JuliaAlgebra/TypedPolynomials.jl May 29, 2020
@blegat blegat linked a pull request May 29, 2020 that will close this issue
@fgerick
Copy link
Author

fgerick commented 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) gives Polynomial{Sym,Term{Sym,Monomial{(x,),1}},Array{Term{Sym,Monomial{(x,),1}},1}}, a very clearly defined type!

@fgerick
Copy link
Author

fgerick commented Sep 22, 2020

is there anything that keeps #144 from being merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants