Skip to content

Commit af4fdfe

Browse files
committed
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.)
1 parent 69abc40 commit af4fdfe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Filters/coefficients.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ PolynomialRatio(b::Poly{T}, a::Poly{T}) where {T<:Number} = PolynomialRatio{T}(b
4646
# The DSP convention is highest power first. The Polynomials.jl
4747
# convention is lowest power first.
4848
function PolynomialRatio(b::Union{T,Vector{T}}, a::Union{S,Vector{S}}) where {T<:Number,S<:Number}
49-
if findfirst(b) == 0 || findfirst(a) == 0
49+
if all(iszero, b) || all(iszero, a)
5050
throw(ArgumentError("filter must have non-zero numerator and denominator"))
5151
end
52-
PolynomialRatio{promote_type(T,S)}(Poly(b[end:-1:findfirst(b)]), Poly(a[end:-1:findfirst(a)]))
52+
PolynomialRatio{promote_type(T,S)}(Poly(reverse(b)), Poly(reverse(a)))
5353
end
5454

5555
Base.promote_rule(::Type{PolynomialRatio{T}}, ::Type{PolynomialRatio{S}}) where {T,S} = PolynomialRatio{promote_type(T,S)}

0 commit comments

Comments
 (0)