Skip to content

Conversions to and from RationalFunction broken #566

@jishnub

Description

@jishnub

Julia nightly demands that convert(T, x) produce a result of type T. This is currently not the case with RationalPolynomials, where promote_rule at various places hard-codes Polynomial instead of using a proper promotion. As a consequence, the following is broken (and tests fail on Julia nightly in general):

julia> r = SparsePolynomial([1,2], :x)
(SparsePolynomial(1 + 2*x)

julia> rr = r // (r-1)
(1 + 2*x) // (2*x)

julia> oftype(rr, r)
ERROR: TypeError: in typeassert, expected RationalFunction{Int64, :x, SparsePolynomial{Int64, :x}}, got a value of type RationalFunction{Int64, :x, Polynomial{Int64, :x}}
Stacktrace:
 [1] oftype(x::RationalFunction{Int64, :x, SparsePolynomial{Int64, :x}}, y::SparsePolynomial{Int64, :x})
   @ Base ./essentials.jl:641
 [2] top-level scope
   @ REPL[12]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions