Skip to content

Commit

Permalink
chore(DataInterpolations): fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutosh-b-b committed Sep 24, 2024
1 parent ce28c4b commit 97529bb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/interpolation_methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function _interpolate(A::LinearInterpolation{<:AbstractArray}, t::Number, iguess
idx = get_idx(A, t, iguess)
Δt = t - A.t[idx]
slope = get_parameters(A, idx)
ax = axes(A.u)[1:end-1]
ax = axes(A.u)[1:(end - 1)]
return A.u[ax..., idx] + slope * Δt
end

Expand Down
4 changes: 2 additions & 2 deletions src/interpolation_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function munge_data(U::AbstractArray{T, N}, t) where {T, N}
TU = Base.nonmissingtype(eltype(U))
Tt = Base.nonmissingtype(eltype(t))
@assert length(t) == size(U, ndims(U))
ax = axes(U)[1:end-1]
ax = axes(U)[1:(end - 1)]
non_missing_indices = collect(
i for i in 1:length(t)
if !any(ismissing, U[ax..., i]) && !ismissing(t[i])
Expand All @@ -107,7 +107,7 @@ function munge_data(U::AbstractArray{T, N}, t) where {T, N}
t = Tt.([t[i] for i in non_missing_indices])

return U, t
end
end

seems_linear(assume_linear_t::Bool, _) = assume_linear_t
seems_linear(assume_linear_t::Number, t) = looks_linear(t; threshold = assume_linear_t)
Expand Down
3 changes: 2 additions & 1 deletion src/parameter_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ end
function linear_interpolation_parameters(u::AbstractArray{T, N}, t, idx) where {T, N}
Δu = if N > 1
ax = axes(u)
safe_diff.(u[ax[1:end-1]..., idx+1:idx+1] , u[ax[1:end-1]..., idx:idx])
safe_diff.(
u[ax[1:(end - 1)]..., (idx + 1):(idx + 1)], u[ax[1:(end - 1)]..., idx:idx])
else
safe_diff(u[idx + 1], u[idx])
end
Expand Down
2 changes: 1 addition & 1 deletion test/interpolation_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end
A = LinearInterpolation(u, t; extrapolate = true)

for (_t, _u) in zip(t, eachcol(u))
@test A(_t) == reshape(_u, : , 1)
@test A(_t) == reshape(_u, :, 1)
end
@test A(0) == [0.0; 0.0;;]
@test A(5.5) == [11.0; 16.5;;]
Expand Down

0 comments on commit 97529bb

Please sign in to comment.