Skip to content

Commit

Permalink
Rework defintion of FloatRange (fix for Julia 1.8)
Browse files Browse the repository at this point in the history
In Julia 1.7, the defintion of `StepRangeLen` acquired another type
parameter, making the fields typed with `FloatRange{Float64}` abstractly
typed. While that is unfortunate but not critical,
JuliaLang/julia#43059 further broke `convert`ing
to this abstract type, causing failures within DSP.jl. This change
reworks the defintion of `FloatRange` to pick the type of an appropriate
`range` call, making it adjust automatically to the changes in Julia. To
simplify things, the type parameter is dropped, as it was only used with
`Float64` anyway.
  • Loading branch information
martinholters committed Jan 17, 2022
1 parent 226ec9f commit 0364d11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/multitaper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ end
struct MTSpectrogramConfig{T,C<:MTConfig{T}}
n_samples::Int
n_overlap_samples::Int
time::FloatRange{Float64}
time::Float64Range
mt_config::C
end

Expand Down
6 changes: 2 additions & 4 deletions src/periodograms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,12 @@ end

## SPECTROGRAM

@static if isdefined(Base, :StepRangeLen)
const FloatRange{T} = StepRangeLen{T,Base.TwicePrecision{T},Base.TwicePrecision{T}}
end
const Float64Range = typeof(range(0.0, step=1.0, length=2))

struct Spectrogram{T,F<:Union{Frequencies,AbstractRange}, M<:AbstractMatrix{T}} <: TFR{T}
power::M
freq::F
time::FloatRange{Float64}
time::Float64Range
end
FFTW.fftshift(p::Spectrogram{T,F}) where {T,F<:Frequencies} =
Spectrogram(p.freq.n_nonnegative == p.freq.n ? p.power : fftshift(p.power, 1), fftshift(p.freq), p.time)
Expand Down

0 comments on commit 0364d11

Please sign in to comment.