From 28d61378d1b4ca222a21c1c5677646daff945f1c Mon Sep 17 00:00:00 2001 From: john verzani Date: Thu, 23 Feb 2023 18:19:28 -0500 Subject: [PATCH] change deprecation to avoid export (#473) * change deprecation to avoid export * rework testing * avoid failure on 1.6 --- Project.toml | 2 +- src/common.jl | 7 ++++++- test/ChebyshevT.jl | 1 - test/StandardBasis.jl | 8 ++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 8a93960d..a8d52f77 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "Polynomials" uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" license = "MIT" author = "JuliaMath" -version = "3.2.4" +version = "3.2.5" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/common.jl b/src/common.jl index 3f3f7ff6..44a10a84 100644 --- a/src/common.jl +++ b/src/common.jl @@ -638,7 +638,12 @@ has a nonzero coefficient. The degree of the zero polynomial is defined to be -1 """ degree(p::AbstractPolynomial) = iszero(coeffs(p)) ? -1 : length(coeffs(p)) - 1 + min(0, minimumexponent(p)) -@deprecate order degree true +function order(p::AbstractPolynomial) + Base.depwarn("The `order` function is deprecated. Use `degree`.", + :AbstractPolynomial) + degree(p) +end + """ Polynomials.domain(::Type{<:AbstractPolynomial}) diff --git a/test/ChebyshevT.jl b/test/ChebyshevT.jl index 6a64dfb5..ec33a2a2 100644 --- a/test/ChebyshevT.jl +++ b/test/ChebyshevT.jl @@ -10,7 +10,6 @@ @test p.coeffs == coeff @test coeffs(p) == coeff @test degree(p) == length(coeff) - 1 - @test (@test_deprecated order(p)) == length(coeff) - 1 @test Polynomials.indeterminate(p) == :x @test length(p) == length(coeff) @test size(p) == size(coeff) diff --git a/test/StandardBasis.jl b/test/StandardBasis.jl index fb107b69..010a42ac 100644 --- a/test/StandardBasis.jl +++ b/test/StandardBasis.jl @@ -147,6 +147,14 @@ Base.getindex(z::ZVector, I::Int) = parent(z)[I + z.offset] @test Polynomials.isconstant(P(1)) @test !Polynomials.isconstant(variable(P)) end + + ## issue #457 + if VERSION >= v"1.7.0" + p = Polynomial([1,2,3]) + @test_warn "deprecated" Polynomials.order(p) + @test Polynomials.order(p) == 2 + end + end @testset "Non-number type" begin