From 85ba4c8dac279c15300f8546f5e93086c5cff15a Mon Sep 17 00:00:00 2001 From: ArnoStrouwen Date: Mon, 26 Feb 2024 05:45:54 +0100 Subject: [PATCH] reapply formatter --- .JuliaFormatter.toml | 3 ++- docs/make.jl | 14 +++++++------- docs/pages.jl | 2 +- docs/src/index.md | 2 +- src/LabelledArrays.jl | 6 +++--- src/larray.jl | 34 ++++++++++++++++++---------------- src/slarray.jl | 22 +++++++++++----------- test/larrays.jl | 2 +- test/runtests.jl | 16 ++++++++++++---- 9 files changed, 56 insertions(+), 45 deletions(-) diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml index 9c79359..959ad88 100644 --- a/.JuliaFormatter.toml +++ b/.JuliaFormatter.toml @@ -1,2 +1,3 @@ style = "sciml" -format_markdown = true \ No newline at end of file +format_markdown = true +format_docstrings = true \ No newline at end of file diff --git a/docs/make.jl b/docs/make.jl index d404b7b..be8fe98 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -6,12 +6,12 @@ cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true) include("pages.jl") makedocs(sitename = "LabelledArrays.jl", - authors = "Chris Rackauckas", - modules = [LabelledArrays], - clean = true, doctest = false, linkcheck = true, - format = Documenter.HTML(assets = ["assets/favicon.ico"], - canonical = "https://docs.sciml.ai/LabelledArrays/stable/"), - pages = pages) + authors = "Chris Rackauckas", + modules = [LabelledArrays], + clean = true, doctest = false, linkcheck = true, + format = Documenter.HTML(assets = ["assets/favicon.ico"], + canonical = "https://docs.sciml.ai/LabelledArrays/stable/"), + pages = pages) deploydocs(repo = "github.com/SciML/LabelledArrays.jl.git"; - push_preview = true) + push_preview = true) diff --git a/docs/pages.jl b/docs/pages.jl index 16cf35b..b804048 100644 --- a/docs/pages.jl +++ b/docs/pages.jl @@ -6,5 +6,5 @@ pages = [ "SLArrays" => "SLArrays.md", "LArrays" => "LArrays.md", "Relation to NamedTuples" => "NamedTuples_relation.md", - "Note_labelled_slices.md", + "Note_labelled_slices.md" ] diff --git a/docs/src/index.md b/docs/src/index.md index 93b0b42..24d053e 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -86,4 +86,4 @@ file and the [project]($link_project) file. """) -``` \ No newline at end of file +``` diff --git a/src/LabelledArrays.jl b/src/LabelledArrays.jl index 7ab6123..98fdc58 100644 --- a/src/LabelledArrays.jl +++ b/src/LabelledArrays.jl @@ -29,7 +29,7 @@ end import Base: eltype, length, ndims, size, axes, eachindex, stride, strides MacroTools.@forward PrintWrapper.x eltype, length, ndims, size, axes, eachindex, stride, - strides +strides Base.getindex(A::PrintWrapper, idxs...) = A.f(A.x, A.x[idxs...], idxs) function lazypair(A, x, idxs) @@ -72,8 +72,8 @@ function ArrayInterface.undefmatrix(x::LArray{T, N, D, Syms}) where {T, N, D, Sy end function PreallocationTools.get_tmp(dc::PreallocationTools.DiffCache, - u::LArray{T, N, D, Syms}) where {T <: ForwardDiff.Dual, - N, D, Syms} + u::LArray{T, N, D, Syms}) where {T <: ForwardDiff.Dual, + N, D, Syms} nelem = div(sizeof(T), sizeof(eltype(dc.dual_du))) * length(dc.du) if nelem > length(dc.dual_du) PreallocationTools.enlargedualcache!(dc, nelem) diff --git a/src/larray.jl b/src/larray.jl index b3491ef..a0f4c45 100644 --- a/src/larray.jl +++ b/src/larray.jl @@ -126,7 +126,7 @@ Base.@propagate_inbounds function Base.getindex(x::LArray, s::AbstractArray{Symb end function Base.similar(x::LArray{T, K, D, Syms}, ::Type{S}, - dims::NTuple{N, Int}) where {T, K, D, Syms, S, N} + dims::NTuple{N, Int}) where {T, K, D, Syms, S, N} tmp = similar(x.__x, S, dims) LArray{S, N, typeof(tmp), Syms}(tmp) end @@ -144,15 +144,15 @@ Base.convert(::Type{T}, x) where {T <: LArray} = T(x) Base.convert(::Type{T}, x::T) where {T <: LArray} = x Base.convert(::Type{<:Array}, x::LArray) = convert(Array, getfield(x, :__x)) function Base.convert(::Type{AbstractArray{T, N}}, - x::LArray{S, N, <:Any, Syms}) where {T, S, N, Syms} + x::LArray{S, N, <:Any, Syms}) where {T, S, N, Syms} LArray{Syms}(convert(AbstractArray{T, N}, getfield(x, :__x))) end Base.convert(::Type{AbstractArray{T, N}}, x::LArray{T, N}) where {T, N} = x function ArrayInterface.restructure(x::LArray{T, N, D, Syms}, - y::LArray{T2, N2, D2, Syms}) where {T, N, D, T2, N2, - D2, - Syms} + y::LArray{T2, N2, D2, Syms}) where {T, N, D, T2, N2, + D2, + Syms} reshape(y, size(x)...) end @@ -163,7 +163,7 @@ struct LAStyle{T, N, L} <: Broadcast.AbstractArrayStyle{N} end LAStyle{T, N, L}(x::Val{i}) where {T, N, L, i} = LAStyle{T, N, L}() Base.BroadcastStyle(::Type{LArray{T, N, D, L}}) where {T, N, D, L} = LAStyle{T, N, L}() function Base.BroadcastStyle(::LabelledArrays.LAStyle{T, N, L}, - ::LabelledArrays.LAStyle{E, N, L}) where {T, E, N, L} + ::LabelledArrays.LAStyle{E, N, L}) where {T, E, N, L} LAStyle{promote_type(T, E), N, L}() end @@ -177,7 +177,7 @@ end end end function Base.similar(bc::Broadcast.Broadcasted{LAStyle{T, N, L}}, - ::Type{ElType}) where {T, N, L, ElType} + ::Type{ElType}) where {T, N, L, ElType} tmp = similar(Array{ElType}, axes(bc)) if axes(bc) != labels2axes(Val(L)) return tmp @@ -368,23 +368,25 @@ For example: B2 = SLArray(B; c=30 ) """ function SLArray(v1::Union{SLArray{S, T, N, L, Syms}, LArray{T, N, D, Syms}}; - kwargs...) where {S, T, N, L, Syms, D} + kwargs...) where {S, T, N, L, Syms, D} t2 = merge(convert(NamedTuple, v1), values(kwargs)) SLArray{S}(t2) end function Base.vcat(x::LArray, y::LArray) - LArray{(LabelledArrays.symnames(typeof(x))..., LabelledArrays.symnames(typeof(y))...)}(vcat(x.__x, - y.__x)) + LArray{(LabelledArrays.symnames(typeof(x))..., LabelledArrays.symnames(typeof(y))...)}(vcat( + x.__x, + y.__x)) end Base.elsize(::Type{<:LArray{T}}) where {T} = sizeof(T) -function RecursiveArrayTools.recursive_unitless_eltype(a::Type{LArray{T, N, D, Syms}}) where { - T, - N, - D, - Syms - } +function RecursiveArrayTools.recursive_unitless_eltype(a::Type{LArray{ + T, N, D, Syms}}) where { + T, + N, + D, + Syms +} LArray{typeof(one(T)), N, D, Syms} end diff --git a/src/slarray.jl b/src/slarray.jl index b756f8f..54e7375 100644 --- a/src/slarray.jl +++ b/src/slarray.jl @@ -29,14 +29,14 @@ end ##################################### ## SLArray to named tuple function Base.convert(::Type{NamedTuple}, - x::SLArray{S, T, N, L, Syms}) where {S, T, N, L, Syms} + x::SLArray{S, T, N, L, Syms}) where {S, T, N, L, Syms} tup = NTuple{length(Syms), T}(x.__x) NamedTuple{Syms, typeof(tup)}(tup) end Base.keys(x::SLArray{S, T, N, L, Syms}) where {S, T, N, L, Syms} = Syms function StaticArrays.similar_type(::Type{SLArray{S, T, N, L, Syms}}, T2, - ::Size{S}) where {S, T, N, L, Syms} + ::Size{S}) where {S, T, N, L, Syms} SLArray{S, T2, N, L, Syms} end function RecursiveArrayTools.recursive_unitless_eltype(a::Type{T}) where {T <: SLArray} @@ -157,8 +157,8 @@ Base.@propagate_inbounds Base.getindex(x::SLArray, i::Int) = getfield(x, :__x)[i @inline Base.Tuple(x::SLArray) = Tuple(x.__x) function StaticArrays.similar_type(::Type{SLArray{S, T, N, L, Syms}}, ::Type{NewElType}, - ::Size{NewSize}) where {S, T, N, L, Syms, NewElType, - NewSize} + ::Size{NewSize}) where {S, T, N, L, Syms, NewElType, + NewSize} n = prod(NewSize) if n == L SLArray{Tuple{NewSize...}, NewElType, length(NewSize), L, Syms} @@ -168,7 +168,7 @@ function StaticArrays.similar_type(::Type{SLArray{S, T, N, L, Syms}}, ::Type{New end function Base.similar(::Type{SLArray{S, T, N, L, Syms}}, ::Type{NewElType}, - ::Size{NewSize}) where {S, T, N, L, Syms, NewElType, NewSize} + ::Size{NewSize}) where {S, T, N, L, Syms, NewElType, NewSize} n = prod(NewSize) if n == L tmp = Array{NewElType}(undef, NewSize) @@ -188,9 +188,9 @@ Base.@propagate_inbounds function Base.getindex(x::SLArray, s::Symbol) end Base.@propagate_inbounds Base.getindex(x::SLArray, s::Val) = __getindex(x, s) Base.@propagate_inbounds function Base.getindex(x::SLArray, - inds::AbstractArray{I, 1}) where { - I <: - Integer} + inds::AbstractArray{I, 1}) where { + I <: + Integer} getindex(x.__x, inds) end Base.@propagate_inbounds function Base.getindex(x::SLArray, inds::StaticVector{<:Any, Int}) @@ -203,7 +203,7 @@ Base.@propagate_inbounds function Base.getindex(x::SLArray, s::AbstractArray{Sym end function Base.vcat(x1::SLArray{S1, T, 1, L1, Syms1}, - x2::SLArray{S2, T, 1, L2, Syms2}) where {S1, S2, T, L1, L2, Syms1, Syms2} + x2::SLArray{S2, T, 1, L2, Syms2}) where {S1, S2, T, L1, L2, Syms1, Syms2} __x = vcat(x1.__x, x2.__x) SLArray{StaticArrays.size_tuple(Size(__x)), (Syms1..., Syms2...)}(__x) end @@ -335,7 +335,7 @@ function Base.:\(A::StaticArrays.LU, b::SLArray{S, T, N, L, Syms}) where {S, T, end function Base.reshape(x::SLArray{S, T, N, L, Syms}, - ax::Tuple{SOneTo, Vararg{SOneTo}}) where {S <: Tuple, T, N, L, Syms, - SOneTo <: SOneTo} + ax::Tuple{SOneTo, Vararg{SOneTo}}) where {S <: Tuple, T, N, L, Syms, + SOneTo <: SOneTo} SLArray{S, T, N, L, Syms}(reshape(x.__x, ax)) end diff --git a/test/larrays.jl b/test/larrays.jl index e8f594d..8a2e69e 100644 --- a/test/larrays.jl +++ b/test/larrays.jl @@ -80,7 +80,7 @@ using LabelledArrays, Test, InteractiveUtils @test_throws ErrorException x.z # Ref #93, #154 - @test_broken @LVector [1, 2, 3] (:a, :b, :c) + @test_broken @LVector [1, 2, 3] (:a, :b, :c) end @testset "Alternate array backends" begin diff --git a/test/runtests.jl b/test/runtests.jl index 787f35e..abe2662 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,8 +5,16 @@ using InteractiveUtils using ChainRulesTestUtils @time begin - @time @testset "SLArrays" begin include("slarrays.jl") end - @time @testset "LArrays" begin include("larrays.jl") end - @time @testset "DiffEq" begin include("diffeq.jl") end - @time @testset "ChainRules" begin include("chainrules.jl") end + @time @testset "SLArrays" begin + include("slarrays.jl") + end + @time @testset "LArrays" begin + include("larrays.jl") + end + @time @testset "DiffEq" begin + include("diffeq.jl") + end + @time @testset "ChainRules" begin + include("chainrules.jl") + end end