From 4035443d27884caeb89a2bbe2c173d36ecca8fee Mon Sep 17 00:00:00 2001 From: Bill Date: Sun, 12 Aug 2018 10:46:52 -1000 Subject: [PATCH 1/7] julia 1.0 iteration uses iterate, not start/next/done --- src/util.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/util.jl b/src/util.jl index c5a9d0208..9a8a9d6bb 100644 --- a/src/util.jl +++ b/src/util.jl @@ -118,9 +118,15 @@ function Base.getindex(x::Frequencies, i::Int) (i >= 1 && i <= x.n) || throw(BoundsError()) unsafe_getindex(x, i) end -Base.start(x::Frequencies) = 1 -Base.next(x::Frequencies, i::Int) = (unsafe_getindex(x, i), i+1) -Base.done(x::Frequencies, i::Int) = i > x.n +if isdefined(Base, :iterate) + function Base.iterate(x::Frequencies, i::Int=1) + i > x.n ? nothing : (unsafe_getindex(x,i), i + 1) + end +else + Base.start(x::Frequencies) = 1 + Base.next(x::Frequencies, i::Int) = (unsafe_getindex(x, i), i+1) + Base.done(x::Frequencies, i::Int) = i > x.n +end Base.size(x::Frequencies) = (x.n,) Base.step(x::Frequencies) = x.multiplier From 95aa0ccfde0d1f7417b0f56c06fd9cf80a9a4f72 Mon Sep 17 00:00:00 2001 From: Bill Date: Sun, 12 Aug 2018 10:49:14 -1000 Subject: [PATCH 2/7] julia 1.0 iteration uses iterate, not start/next/done --- src/periodograms.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/periodograms.jl b/src/periodograms.jl index 7c7f6ee10..9ac590e4a 100644 --- a/src/periodograms.jl +++ b/src/periodograms.jl @@ -43,9 +43,15 @@ function Base.getindex(x::ArraySplit{T,S,W}, i::Int) where {T,S,W} end x.buf end -Base.start(x::ArraySplit) = 1 -Base.next(x::ArraySplit, i::Int) = (x[i], i+1) -Base.done(x::ArraySplit, i::Int) = i > x.k +if isdefined(Base, :iterate) + function Base.iterate(x::ArraySplit, i::Int = 1) + i > x.k ? nothing : (x[i], i+1) + end +else + Base.start(x::ArraySplit) = 1 + Base.next(x::ArraySplit, i::Int) = (x[i], i+1) + Base.done(x::ArraySplit, i::Int) = i > x.k +end Base.size(x::ArraySplit) = (x.k,) """ From b488ba7e668d01d10d89568c8b5189452fe352cf Mon Sep 17 00:00:00 2001 From: Spencer Russell Date: Tue, 14 Aug 2018 17:37:13 -0400 Subject: [PATCH 3/7] some more 0.7 deprecations --- src/Filters/filt.jl | 6 +++--- src/dspbase.jl | 2 +- test/filt.jl | 2 +- test/runtests.jl | 6 +++++- test/unwrap.jl | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Filters/filt.jl b/src/Filters/filt.jl index b6780674c..218444edb 100644 --- a/src/Filters/filt.jl +++ b/src/Filters/filt.jl @@ -560,7 +560,7 @@ function _fftfilt!(out::AbstractArray{T}, b::AbstractVector{T}, x::AbstractArray # FFT of filter filterft = similar(tmp2) copyto!(tmp1, b) - tmp1[nb+1:end] = zero(T) + tmp1[nb+1:end] .= zero(T) mul!(filterft, p1, tmp1) # FFT of chunks @@ -571,8 +571,8 @@ function _fftfilt!(out::AbstractArray{T}, b::AbstractVector{T}, x::AbstractArray xstart = off - nb + npadbefore + 1 n = min(nfft - npadbefore, nx - xstart + 1) - tmp1[1:npadbefore] = zero(T) - tmp1[npadbefore+n+1:end] = zero(T) + tmp1[1:npadbefore] .= zero(T) + tmp1[npadbefore+n+1:end] .= zero(T) copyto!(tmp1, npadbefore+1, x, colstart+xstart, n) mul!(tmp2, p1, tmp1) diff --git a/src/dspbase.jl b/src/dspbase.jl index 7bad82421..6540e9195 100644 --- a/src/dspbase.jl +++ b/src/dspbase.jl @@ -126,7 +126,7 @@ function conv(u::StridedVector{T}, v::StridedVector{T}) where T<:BLAS.BlasFloat nu = length(u) nv = length(v) n = nu + nv - 1 - np2 = n > 1024 ? nextprod([2,3,5], n) : nextpow2(n) + np2 = n > 1024 ? nextprod([2,3,5], n) : nextpow(2, n) upad = [u; zeros(T, np2 - nu)] vpad = [v; zeros(T, np2 - nv)] if T <: Real diff --git a/test/filt.jl b/test/filt.jl index 0fc465ed1..9f05a48ec 100644 --- a/test/filt.jl +++ b/test/filt.jl @@ -4,7 +4,7 @@ using DSP, Compat, Compat.Test, Compat.Random, FilterTestHelpers # filt with different filter forms # @testset "filt" begin - srand(1776) + seed!(1776) x = randn(100) for n = 1:6 diff --git a/test/runtests.jl b/test/runtests.jl index 6773f142b..ad2f93d6f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,9 @@ using Compat, DSP, AbstractFFTs, FFTW, Compat.Test +if VERSION >= v"0.7.0-beta.171" + using Random: seed! +else + seed!(x) = srand(x) +end testfiles = [ "dsp.jl", "util.jl", "windows.jl", "filter_conversion.jl", "filter_design.jl", "filter_response.jl", "filt.jl", "filt_stream.jl", @@ -8,4 +13,3 @@ testfiles = [ "dsp.jl", "util.jl", "windows.jl", "filter_conversion.jl", for testfile in testfiles eval(:(@testset $testfile begin include($testfile) end)) end - diff --git a/test/unwrap.jl b/test/unwrap.jl index c99f34584..0b93e0419 100644 --- a/test/unwrap.jl +++ b/test/unwrap.jl @@ -39,7 +39,7 @@ using DSP, Compat, Compat.Test # test generically typed unwrapping types = (Float32, Float64, BigFloat) for T in types - srand(1234) + seed!(1234) A_unwrapped = collect(Compat.range(0, stop=4convert(T, π), length=10)) A_wrapped = A_unwrapped .% (2convert(T, π)) @@ -58,7 +58,7 @@ end @testset "Unwrap 2D" begin types = (Float32, Float64, BigFloat) for T in types - srand(1234) + seed!(1234) v_unwrapped = collect(Compat.range(0, stop=4convert(T, π), length=7)) A_unwrapped = v_unwrapped .+ v_unwrapped' A_wrapped = A_unwrapped .% (2convert(T, π)) From c44debd1fa2dd73ec15b110fe56801d4180bb76e Mon Sep 17 00:00:00 2001 From: Spencer Russell Date: Tue, 14 Aug 2018 17:39:25 -0400 Subject: [PATCH 4/7] now testing on 1.0 and allowing failures on nightly --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2f2d5940d..237d2894a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,11 @@ os: julia: - 0.6 - 0.7 + - 1.0 - nightly +matrix: + allow_failures: + - julia: nightly notifications: email: false script: From f5c2656a5ac6de66055d063c1933f3c67bd38f8b Mon Sep 17 00:00:00 2001 From: Spencer Russell Date: Tue, 14 Aug 2018 18:28:41 -0400 Subject: [PATCH 5/7] conditionally imports Pkg in travis.yml --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 237d2894a..76af97596 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,9 @@ notifications: email: false script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia --check-bounds=yes -e 'Pkg.clone(pwd()); Pkg.build("DSP"); Pkg.test("DSP"; coverage=true)' + - julia --check-bounds=yes -e 'if (VERSION >= v"0.7.0") using Pkg; Pkg.add(pwd()) else Pkg.clone(pwd()); end; + Pkg.build("DSP"); + Pkg.test("DSP"; coverage=true)' after_success: - julia -e 'cd(Pkg.dir("DSP")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' - julia -e 'Pkg.add("Documenter"); cd(Pkg.dir("DSP")); include(joinpath("docs", "make.jl"))' From d0315a91d6fbdfcd83bdefe04c463970a9b73213 Mon Sep 17 00:00:00 2001 From: Spencer Russell Date: Tue, 14 Aug 2018 18:34:18 -0400 Subject: [PATCH 6/7] removes script block to use the default julia stuff --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76af97596..ee93e1bd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,11 +11,6 @@ matrix: - julia: nightly notifications: email: false -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia --check-bounds=yes -e 'if (VERSION >= v"0.7.0") using Pkg; Pkg.add(pwd()) else Pkg.clone(pwd()); end; - Pkg.build("DSP"); - Pkg.test("DSP"; coverage=true)' after_success: - julia -e 'cd(Pkg.dir("DSP")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' - julia -e 'Pkg.add("Documenter"); cd(Pkg.dir("DSP")); include(joinpath("docs", "make.jl"))' From 7538609cf4a11f3da640790cd5b71e779eff9efd Mon Sep 17 00:00:00 2001 From: Spencer Russell Date: Tue, 14 Aug 2018 18:50:14 -0400 Subject: [PATCH 7/7] updates coverage and doc generation to work on 1.0 --- .travis.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee93e1bd4..06ab33003 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,16 @@ julia: matrix: allow_failures: - julia: nightly + fast_finish: true notifications: email: false after_success: - - julia -e 'cd(Pkg.dir("DSP")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' - - julia -e 'Pkg.add("Documenter"); cd(Pkg.dir("DSP")); include(joinpath("docs", "make.jl"))' + - julia -e 'VERSION >= v"0.7.0-DEV.5183" && using Pkg; + VERSION >= v"0.7.0-DEV.5183" || cd(Pkg.dir("DSP")); + Pkg.add("Coverage"); + using Coverage; + Coveralls.submit(Coveralls.process_folder())' + - julia -e 'VERSION >= v"0.7.0-DEV.5183" && using Pkg; + VERSION >= v"0.7.0-DEV.5183" || cd(Pkg.dir("DSP")); + Pkg.add("Documenter"); + include(joinpath("docs", "make.jl"))'