From af4fdfe266ede1bf2094bcdf1aae8dd28d84d60a Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 29 Sep 2017 10:07:39 +0200 Subject: [PATCH] Avoid `findfirst` in `PolynomialRatio` constructor This fixes the deprecations due to JuliaLang/julia#23812 and makes for cleaner code anyway. (Truncation of trailing zeros is done in the `Poly` constructor so there is no need to do it here.) --- src/Filters/coefficients.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Filters/coefficients.jl b/src/Filters/coefficients.jl index 63fe858eb..33b470f2a 100644 --- a/src/Filters/coefficients.jl +++ b/src/Filters/coefficients.jl @@ -46,10 +46,10 @@ PolynomialRatio(b::Poly{T}, a::Poly{T}) where {T<:Number} = PolynomialRatio{T}(b # The DSP convention is highest power first. The Polynomials.jl # convention is lowest power first. function PolynomialRatio(b::Union{T,Vector{T}}, a::Union{S,Vector{S}}) where {T<:Number,S<:Number} - if findfirst(b) == 0 || findfirst(a) == 0 + if all(iszero, b) || all(iszero, a) throw(ArgumentError("filter must have non-zero numerator and denominator")) end - PolynomialRatio{promote_type(T,S)}(Poly(b[end:-1:findfirst(b)]), Poly(a[end:-1:findfirst(a)])) + PolynomialRatio{promote_type(T,S)}(Poly(reverse(b)), Poly(reverse(a))) end Base.promote_rule(::Type{PolynomialRatio{T}}, ::Type{PolynomialRatio{S}}) where {T,S} = PolynomialRatio{promote_type(T,S)}