Skip to content

Commit

Permalink
Update to Julia 1.10 synthax
Browse files Browse the repository at this point in the history
-Range renamed AbstractRange
JuliaLang/julia#23570

-squeeze renamed dropdims

-immutable renamed struct
JuliaLang/julia#20418
  • Loading branch information
Bachibouzouk committed Jul 22, 2024
1 parent 56d1d7a commit a932943
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ linear(g::TimeGrid, s::System, p::HilbertPath{3}) = amplitude(s,p)*linear(g, ene
linear(g::TimeGrid, s::System) = sum(p->linear(g, s, p), hilbert_paths(s, 1))
linear(t1::Real, ws::NTuple{1, Real}, ls::NTuple{1,Any}) = linear(t1, ws..., ls...)
linear(g::TimeGrid{<:Real,1}, ws::NTuple{1, Real}, ls::NTuple{1,Any}) = linear(first(grid(g)), ws..., ls...) # could be fed to the @eval loop.
linear(g::TimeGrid, ws::NTuple{1, Real}, ls::NTuple{1,Any}) = linear(squeeze(first(grid(g))), ws..., ls...) # could be fed to the @eval loop.
linear(g::TimeGrid, ws::NTuple{1, Real}, ls::NTuple{1,Any}) = linear(dropdims(first(grid(g))), ws..., ls...) # could be fed to the @eval loop.
linear(t1::Array{<:Real,1}, ws::Real, ls) = linear.(t1, ws, ls)

# Use the @eval macro to operate on R1 to R4.
Expand Down
2 changes: 1 addition & 1 deletion src/hilbert_path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ True if any element is identical to the next. Naive implementation
consecutive(a) = any(a[2:end] .== a[1:end-1])

"""Hilbert Path of order N-2"""
immutable HilbertPath{N}
struct HilbertPath{N}
p::NTuple{N,String}
end
HilbertPath(args::Vararg{String,N}) where {N} = HilbertPath{N}(args)
Expand Down
2 changes: 1 addition & 1 deletion src/lineshapes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ end
function LineshapeLUT(lut::Array{Tls,1}, dx::Tx) where {Tls, Tx}
LineshapeLUT{Tx, Tls}(lut, dx)
end
function LineshapeLUT(f, x::Range{Tx}) where {Tx}#, Tls}
function LineshapeLUT(f, x::AbstractRange{Tx}) where {Tx}#, Tls}
gx = f.(x)
LineshapeLUT{Tx,eltype(gx)}(gx, step(x))
end
Expand Down
2 changes: 1 addition & 1 deletion src/time_correlation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export GriddedCF

# externally computed on a constant grid. Allow specific points only.
immutable GriddedCF{Tg<:Real, Tcf<:Number}
struct GriddedCF{Tg<:Real, Tcf<:Number}
lut::Array{Tcf,1}
Im::Tcf
dt::Tg
Expand Down
2 changes: 1 addition & 1 deletion src/time_grid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Base.size(tg::TimeGrid) = map(length, tg.times)
# to find a greater common divisor (gcd) for floats:
# https://www.geeksforgeeks.org/program-find-gcd-floating-point-numbers/

t_to_f(t::Range) = fftshift(fftfreq(length(t), 1/step(t)))
t_to_f(t::AbstractRange) = fftshift(fftfreq(length(t), 1/step(t)))
# use mean step. Hopefully doesn't matter.
t_to_f(t::AbstractArray{<:Real, 1}) = fftshift(fftfreq(length(t), 1/mean(diff(t))))
"""
Expand Down
7 changes: 4 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ function simps(y, h::Number)
s = sum(y[1:2:n] + 4y[2:2:n]+y[3:2:n+1])
h/3*s + tail
end
#simps(y, h::Base.TwicePrecision{T}) where {T<:AbstractFloat} = simps(y, h.hi)
simps(y, x::Range{T}) where {T} = simps(y, step(x))
#simps(y, h::Base.TwicePrecision{T}) where {T<:AbstractFloat} = simps(y, h.hi)

simps(y, x::AbstractRange{T}) where {T} = simps(y, step(x))

"""
Sum a series until convergence.
Expand All @@ -36,4 +37,4 @@ end

# convenience
"""Squeeze all dimensions of length 1"""
Base.squeeze(A::AbstractArray) = squeeze(A, tuple(find(size(A).==1)...))
Base.dropdims(A::AbstractArray) = dropdims(A, tuple(find(size(A).==1)...))

0 comments on commit a932943

Please sign in to comment.