From 97529bb656ba64fe543964c4bdd66fa8b6f8d429 Mon Sep 17 00:00:00 2001 From: Ashutosh Bharambe Date: Tue, 24 Sep 2024 10:24:11 +0000 Subject: [PATCH] chore(DataInterpolations): fix formatting --- src/interpolation_methods.jl | 2 +- src/interpolation_utils.jl | 4 ++-- src/parameter_caches.jl | 3 ++- test/interpolation_tests.jl | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/interpolation_methods.jl b/src/interpolation_methods.jl index 26298b8f..03adf558 100644 --- a/src/interpolation_methods.jl +++ b/src/interpolation_methods.jl @@ -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 diff --git a/src/interpolation_utils.jl b/src/interpolation_utils.jl index 4037d810..f8fc7147 100644 --- a/src/interpolation_utils.jl +++ b/src/interpolation_utils.jl @@ -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]) @@ -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) diff --git a/src/parameter_caches.jl b/src/parameter_caches.jl index 83f574b8..824b2e2a 100644 --- a/src/parameter_caches.jl +++ b/src/parameter_caches.jl @@ -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 diff --git a/test/interpolation_tests.jl b/test/interpolation_tests.jl index 38c424de..69e5c197 100644 --- a/test/interpolation_tests.jl +++ b/test/interpolation_tests.jl @@ -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;;]