Skip to content

remove promote_rule method; add type information to any definition #440

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

Merged
merged 2 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Polynomials"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
license = "MIT"
author = "JuliaMath"
version = "3.1.6"
version = "3.1.7"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
7 changes: 2 additions & 5 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,6 @@ function Base.convert(::Type{T}, p::AbstractPolynomial{T,X}) where {T <: Number,
end

# Methods to ensure that matrices of polynomials behave as desired
Base.promote_rule(::Type{<:AbstractPolynomial{T}},
::Type{<:AbstractPolynomial{S}},
) where {T,S} = Polynomial{promote_type(T, S)}
Base.promote_rule(::Type{P},::Type{Q}) where {T,X, P<:AbstractPolynomial{T,X},
S, Q<:AbstractPolynomial{S,X}} =
Polynomial{promote_type(T, S),X}
Expand Down Expand Up @@ -479,13 +476,13 @@ Test whether all coefficients of an `AbstractPolynomial` satisfy predicate `pred

You can implement `isreal`, etc., to a `Polynomial` by using `all`.
"""
Base.all(pred, p::AbstractPolynomial) = all(pred, values(p))
Base.all(pred, p::AbstractPolynomial{T, X}) where {T,X} = all(pred, values(p))
"""
any(pred, poly::AbstractPolynomial)

Test whether any coefficient of an `AbstractPolynomial` satisfies predicate `pred`.
"""
Base.any(pred, p::AbstractPolynomial) = any(pred, values(p))
Base.any(pred, p::AbstractPolynomial{T,X}) where {T, X} = any(pred, values(p))



Expand Down
5 changes: 4 additions & 1 deletion src/polynomials/ChebyshevT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ function Base.convert(C::Type{<:ChebyshevT}, p::Polynomial)
p(x)
end

Base.promote_rule(::Type{P},::Type{Q}) where {T, X, P <: LaurentPolynomial{T,X}, S, Q <: ChebyshevT{S, X}} = LaurentPolynomial{promote_type(T, S), X}
Base.promote_rule(::Type{P},::Type{Q}) where {
T, X, P <: LaurentPolynomial{T,X},
S, Q <: ChebyshevT{S, X}} =
LaurentPolynomial{promote_type(T, S), X}

domain(::Type{<:ChebyshevT}) = Interval(-1, 1)
function Base.one(::Type{P}) where {P<:ChebyshevT}
Expand Down