diff --git a/ext/DataInterpolationsOptimExt.jl b/ext/DataInterpolationsOptimExt.jl index 3d080b83..5db14436 100644 --- a/ext/DataInterpolationsOptimExt.jl +++ b/ext/DataInterpolationsOptimExt.jl @@ -76,8 +76,8 @@ function _interpolate(A::CurvefitCache{<:AbstractVector{<:Number}}, end function get_show(interp::CurvefitCache) - return "Curvefit" * " with $(length(interp.t)) points, using $(nameof(typeof(interp.alg)))\n" + return "Curvefit" * + " with $(length(interp.t)) points, using $(nameof(typeof(interp.alg)))\n" end - end # module diff --git a/ext/DataInterpolationsRegularizationToolsExt.jl b/ext/DataInterpolationsRegularizationToolsExt.jl index 1d379e53..c7abda64 100644 --- a/ext/DataInterpolationsRegularizationToolsExt.jl +++ b/ext/DataInterpolationsRegularizationToolsExt.jl @@ -270,7 +270,8 @@ function DataInterpolations._interpolate(A::RegularizationSmooth{ end function DataInterpolations.get_show(interp::RegularizationSmooth) - return "RegularizationSmooth" * " with $(length(interp.t)) points, with regularization coefficient $(interp.λ)\n" + return "RegularizationSmooth" * + " with $(length(interp.t)) points, with regularization coefficient $(interp.λ)\n" end end # module diff --git a/src/show.jl b/src/show.jl index e00dcaae..7ce1e006 100644 --- a/src/show.jl +++ b/src/show.jl @@ -11,15 +11,15 @@ function get_show(interp::AbstractInterpolation) return string(nameof(typeof(interp))) * " with $(length(interp.t)) points\n" end -function get_data(u::AbstractVector) +function get_data(u::AbstractVector) return u end -function get_data(u::AbstractVector{<:AbstractVector}) +function get_data(u::AbstractVector{<:AbstractVector}) return reduce(hcat, u)' end -function get_data(u::AbstractMatrix) +function get_data(u::AbstractMatrix) return u' end @@ -38,28 +38,26 @@ end ###################### Specific Dispatches ###################### function get_show(interp::QuadraticInterpolation) - return string(nameof(typeof(interp))) * " with $(length(interp.t)) points, $(interp.mode) mode\n" + return string(nameof(typeof(interp))) * + " with $(length(interp.t)) points, $(interp.mode) mode\n" end function get_show(interp::LagrangeInterpolation) - return string(nameof(typeof(interp))) * " with $(length(interp.t)) points, with order $(interp.n)\n" + return string(nameof(typeof(interp))) * + " with $(length(interp.t)) points, with order $(interp.n)\n" end function get_show(interp::ConstantInterpolation) - return string(nameof(typeof(interp))) * " with $(length(interp.t)) points, in $(interp.dir) direction\n" + return string(nameof(typeof(interp))) * + " with $(length(interp.t)) points, in $(interp.dir) direction\n" end function get_show(interp::BSplineInterpolation) - return string(nameof(typeof(interp))) * " with $(length(interp.t)) points, with degree $(interp.d)\n" + return string(nameof(typeof(interp))) * + " with $(length(interp.t)) points, with degree $(interp.d)\n" end function get_show(interp::BSplineApprox) - return string(nameof(typeof(interp))) * " with $(length(interp.t)) points, with degree $(interp.d), number of control points $(interp.h)\n" + return string(nameof(typeof(interp))) * + " with $(length(interp.t)) points, with degree $(interp.d), number of control points $(interp.h)\n" end - - - - - - - diff --git a/test/show.jl b/test/show.jl index bd8ecd17..2dcbfb96 100644 --- a/test/show.jl +++ b/test/show.jl @@ -7,7 +7,8 @@ x = [1.0, 2.0, 3.0, 4.0, 5.0] @testset "Generic Cases" begin function test_show_line(A) @testset "$(nameof(typeof(A)))" begin - @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), "$(nameof(typeof(A))) with $(length(A.t)) points\n") + @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), + "$(nameof(typeof(A))) with $(length(A.t)) points\n") end end methods = [ @@ -22,23 +23,28 @@ end @testset "Specific Cases" begin @testset "QuadraticInterpolation" begin A = QuadraticInterpolation(x, t) - @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), "QuadraticInterpolation with 5 points, Forward mode\n") + @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), + "QuadraticInterpolation with 5 points, Forward mode\n") end @testset "LagrangeInterpolation" begin A = LagrangeInterpolation(x, t) - @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), "LagrangeInterpolation with 5 points, with order 4\n") + @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), + "LagrangeInterpolation with 5 points, with order 4\n") end @testset "ConstantInterpolation" begin A = ConstantInterpolation(x, t) - @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), "ConstantInterpolation with 5 points, in left direction\n") + @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), + "ConstantInterpolation with 5 points, in left direction\n") end @testset "BSplineInterpolation" begin A = BSplineInterpolation(x, t, 3, :Uniform, :Uniform) - @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), "BSplineInterpolation with 5 points, with degree 3\n") + @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), + "BSplineInterpolation with 5 points, with degree 3\n") end @testset "BSplineApprox" begin A = BSplineApprox(x, t, 2, 4, :Uniform, :Uniform) - @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), "BSplineApprox with 5 points, with degree 2, number of control points 4\n") + @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), + "BSplineApprox with 5 points, with degree 2, number of control points 4\n") end end @@ -49,7 +55,8 @@ end u = model(t, [1.0, 2.0]) + 0.01 * randn(rng, length(t)) p0 = [0.5, 0.5] A = Curvefit(u, t, model, p0, LBFGS()) - @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), "Curvefit with 40 points, using LBFGS\n") + @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), + "Curvefit with 40 points, using LBFGS\n") end @testset "RegularizationSmooth" begin @@ -71,5 +78,6 @@ end tₒ = t[idx] uₒ = u[idx] A = RegularizationSmooth(uₒ, tₒ; alg = :fixed) - @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), "RegularizationSmooth with 15 points, with regularization coefficient 1.0\n") -end \ No newline at end of file + @test startswith(sprint(io -> show(io, MIME"text/plain"(), A)), + "RegularizationSmooth with 15 points, with regularization coefficient 1.0\n") +end