Skip to content

Commit 4a29fe0

Browse files
committed
Switch from JuliaFormatter to Runic.jl for code formatting
- Update CI workflow to use fredrikekre/runic-action@v1 - Remove .JuliaFormatter.toml configuration - Format all source files with Runic.jl 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent b54f122 commit 4a29fe0

File tree

12 files changed

+215
-139
lines changed

12 files changed

+215
-139
lines changed

.JuliaFormatter.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/FormatCheck.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
name: "Format Check"
1+
name: format-check
22

33
on:
44
push:
55
branches:
66
- 'master'
7+
- 'main'
8+
- 'release-'
79
tags: '*'
810
pull_request:
911

1012
jobs:
11-
format-check:
12-
name: "Format Check"
13-
uses: "SciML/.github/.github/workflows/format-check.yml@v1"
13+
runic:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: fredrikekre/runic-action@v1
18+
with:
19+
version: '1'

docs/make.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
55

66
include("pages.jl")
77

8-
makedocs(sitename = "LabelledArrays.jl",
8+
makedocs(
9+
sitename = "LabelledArrays.jl",
910
authors = "Chris Rackauckas",
1011
modules = [LabelledArrays],
1112
clean = true, doctest = false, linkcheck = true,
12-
format = Documenter.HTML(assets = ["assets/favicon.ico"],
13-
canonical = "https://docs.sciml.ai/LabelledArrays/stable/"),
14-
pages = pages)
13+
format = Documenter.HTML(
14+
assets = ["assets/favicon.ico"],
15+
canonical = "https://docs.sciml.ai/LabelledArrays/stable/"
16+
),
17+
pages = pages
18+
)
1519

16-
deploydocs(repo = "github.com/SciML/LabelledArrays.jl.git";
17-
push_preview = true)
20+
deploydocs(
21+
repo = "github.com/SciML/LabelledArrays.jl.git";
22+
push_preview = true
23+
)

docs/pages.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ pages = [
66
"SLArrays" => "SLArrays.md",
77
"LArrays" => "LArrays.md",
88
"Relation to NamedTuples" => "NamedTuples_relation.md",
9-
"Note: Labelled Slices" => "Note_labelled_slices.md"
9+
"Note: Labelled Slices" => "Note_labelled_slices.md",
1010
]

src/LabelledArrays.jl

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ include("diffeqarray.jl")
1212
@generated function __getindex(x::Union{LArray, SLArray}, ::Val{s}) where {s}
1313
syms = symnames(x)
1414
idx = syms isa NamedTuple ? syms[s] : findfirst(y -> y == s, syms)
15-
if idx === nothing
15+
return if idx === nothing
1616
:(error("type $(typeof(x)) has no field $(s)"))
1717
elseif idx isa Tuple
1818
:(Base.@_propagate_inbounds_meta; view(getfield(x, :__x), $idx...))
@@ -30,18 +30,18 @@ end
3030

3131
import Base: eltype, length, ndims, size, axes, eachindex, stride, strides
3232
MacroTools.@forward PrintWrapper.x eltype, length, ndims, size, axes, eachindex, stride,
33-
strides
33+
strides
3434
Base.getindex(A::PrintWrapper, idxs...) = A.f(A.x, A.x[idxs...], idxs)
3535

3636
function lazypair(A, x, idxs)
3737
syms = symnames(typeof(A))
3838
II = LinearIndices(A)
3939
key = eltype(syms) <: Symbol ? syms[II[idxs...]] :
40-
findfirst(syms) do sym
41-
ii = idxs isa Tuple ? II[idxs...] : II[idxs]
42-
sym isa Tuple ? ii in II[sym...] : ii in II[sym]
40+
findfirst(syms) do sym
41+
ii = idxs isa Tuple ? II[idxs...] : II[idxs]
42+
sym isa Tuple ? ii in II[sym...] : ii in II[sym]
4343
end
44-
key => x
44+
return key => x
4545
end
4646

4747
Base.show(io::IO, ::MIME"text/plain", x::Union{LArray, SLArray}) = show(io, x)
@@ -50,37 +50,41 @@ function Base.show(io::IO, x::Union{LArray, SLArray})
5050
n = length(syms)
5151
pwrapper = PrintWrapper(lazypair, x)
5252
if io isa IOContext && get(io, :limit, false) &&
53-
displaysize(io) isa Tuple{Integer, Integer}
53+
displaysize(io) isa Tuple{Integer, Integer}
5454
io = IOContext(io, :limit => true, :displaysize => cld.(2 .* displaysize(io), 3))
5555
end
5656
println(io, summary(x), ':')
57-
Base.print_array(io, pwrapper)
57+
return Base.print_array(io, pwrapper)
5858
end
5959

6060
Base.NamedTuple(x::Union{LArray, SLArray}) = NamedTuple{symnames(typeof(x))}(x.__x)
6161
@inline Base.reshape(a::SLArray, s::Size) = StaticArrays.similar_type(a, s)(Tuple(a))
6262

6363
function ArrayInterface.ismutable(::Type{<:LArray{T, N, D, Syms}}) where {T, N, D, Syms}
64-
ArrayInterface.ismutable(T)
64+
return ArrayInterface.ismutable(T)
6565
end
6666
ArrayInterface.can_setindex(::Type{<:SLArray}) = false
6767

6868
lenfun(x) = length(x)
6969
lenfun(::Symbol) = 1
7070
function ArrayInterface.undefmatrix(x::LArray{T, N, D, Syms}) where {T, N, D, Syms}
7171
n = sum(lenfun, Syms)
72-
similar(x.__x, n, n)
72+
return similar(x.__x, n, n)
7373
end
7474

75-
function PreallocationTools.get_tmp(dc::PreallocationTools.DiffCache,
76-
u::LArray{T, N, D, Syms}) where {T <: ForwardDiff.Dual,
77-
N, D, Syms}
75+
function PreallocationTools.get_tmp(
76+
dc::PreallocationTools.DiffCache,
77+
u::LArray{T, N, D, Syms}
78+
) where {
79+
T <: ForwardDiff.Dual,
80+
N, D, Syms,
81+
}
7882
nelem = div(sizeof(T), sizeof(eltype(dc.dual_du))) * length(dc.du)
7983
if nelem > length(dc.dual_du)
8084
PreallocationTools.enlargedualcache!(dc, nelem)
8185
end
8286
_x = ArrayInterface.restructure(dc.du, reinterpret(T, view(dc.dual_du, 1:nelem)))
83-
LabelledArrays.LArray{T, N, D, Syms}(_x)
87+
return LabelledArrays.LArray{T, N, D, Syms}(_x)
8488
end
8589

8690
export SLArray, LArray, SLVector, LVector, @SLVector, @LArray, @LVector, @SLArray

src/diffeqarray.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
for LArrayType in [LArray, SLArray]
2-
@eval function RecursiveArrayTools.DiffEqArray(vec::AbstractVector{<:$LArrayType},
2+
@eval function RecursiveArrayTools.DiffEqArray(
3+
vec::AbstractVector{<:$LArrayType},
34
ts::AbstractVector,
4-
p = nothing)
5-
RecursiveArrayTools.DiffEqArray(vec, ts, p; variables = collect(symbols(vec[1])))
5+
p = nothing
6+
)
7+
return RecursiveArrayTools.DiffEqArray(vec, ts, p; variables = collect(symbols(vec[1])))
68
end
79
end

src/larray.jl

Lines changed: 60 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ end
66

77
function LArray{T, N, D, Syms}(::UndefInitializer, n::Int64) where {T, N, D, Syms}
88
@assert sum(lenfun, Syms) == n
9-
LArray{T, N, D, Syms}(similar(D, n))
9+
return LArray{T, N, D, Syms}(similar(D, n))
1010
end
1111

1212
#####################################
@@ -15,7 +15,7 @@ end
1515
## LArray to named tuple
1616
function Base.convert(::Type{NamedTuple}, x::LArray{T, N, D, Syms}) where {T, N, D, Syms}
1717
tup = NTuple{length(Syms), T}(x)
18-
NamedTuple{Syms, typeof(tup)}(tup)
18+
return NamedTuple{Syms, typeof(tup)}(tup)
1919
end
2020
Base.keys(x::LArray{T, N, D, Syms}) where {T, N, D, Syms} = Syms
2121

@@ -43,7 +43,7 @@ LArray((2, 2); a = 1, b = 2, c = 3, d = 4)
4343
"""
4444
function LArray(size::NTuple{S, Int}, tup::NamedTuple{Syms, Tup}) where {S, Syms, Tup}
4545
__x = reshape(collect(tup), size)
46-
LArray{Syms}(__x)
46+
return LArray{Syms}(__x)
4747
end
4848
LArray(size::NTuple{S, Int}; kwargs...) where {S} = LArray(size, values(kwargs))
4949

@@ -68,7 +68,7 @@ LVector(; kwargs...) = LVector(values(kwargs))
6868
## pairs iterator
6969
function Base.pairs(x::LArray{T, N, D, Syms}) where {T, N, D, Syms}
7070
# (label => getproperty(x, label) for label in Syms) # not type stable?
71-
(Syms[i] => x[i] for i in 1:length(Syms))
71+
return (Syms[i] => x[i] for i in 1:length(Syms))
7272
end
7373

7474
#####################################
@@ -95,7 +95,7 @@ Base.@propagate_inbounds function Base.setproperty!(x::LArray, s::Symbol, y)
9595
if s == :__x
9696
return setfield!(x, :__x, y)
9797
end
98-
setindex!(x, y, Val(s))
98+
return setindex!(x, y, Val(s))
9999
end
100100

101101
Base.@propagate_inbounds Base.getindex(x::LArray, s::Symbol) = getindex(x, Val(s))
@@ -122,13 +122,15 @@ Base.@propagate_inbounds Base.setindex!(x::LArray, v, s::Symbol) = setindex!(x,
122122
end
123123

124124
Base.@propagate_inbounds function Base.getindex(x::LArray, s::AbstractArray{Symbol, 1})
125-
[getindex(x, si) for si in s]
125+
return [getindex(x, si) for si in s]
126126
end
127127

128-
function Base.similar(x::LArray{T, K, D, Syms}, ::Type{S},
129-
dims::NTuple{N, Int}) where {T, K, D, Syms, S, N}
128+
function Base.similar(
129+
x::LArray{T, K, D, Syms}, ::Type{S},
130+
dims::NTuple{N, Int}
131+
) where {T, K, D, Syms, S, N}
130132
tmp = similar(x.__x, S, dims)
131-
LArray{S, N, typeof(tmp), Syms}(tmp)
133+
return LArray{S, N, typeof(tmp), Syms}(tmp)
132134
end
133135

134136
# Allow copying LArray of uninitialized data, as with regular Array
@@ -137,23 +139,29 @@ Base.copyto!(x::LArray, y::LArray) = copyto!(getfield(x, :__x), getfield(y, :__x
137139

138140
# enable the usage of LAPACK
139141
function Base.unsafe_convert(::Type{Ptr{T}}, a::LArray{T, N, D, S}) where {T, N, D, S}
140-
Base.unsafe_convert(Ptr{T}, getfield(a, :__x))
142+
return Base.unsafe_convert(Ptr{T}, getfield(a, :__x))
141143
end
142144

143145
Base.convert(::Type{T}, x) where {T <: LArray} = T(x)
144146
Base.convert(::Type{T}, x::T) where {T <: LArray} = x
145147
Base.convert(::Type{<:Array}, x::LArray) = convert(Array, getfield(x, :__x))
146-
function Base.convert(::Type{AbstractArray{T, N}},
147-
x::LArray{S, N, <:Any, Syms}) where {T, S, N, Syms}
148-
LArray{Syms}(convert(AbstractArray{T, N}, getfield(x, :__x)))
148+
function Base.convert(
149+
::Type{AbstractArray{T, N}},
150+
x::LArray{S, N, <:Any, Syms}
151+
) where {T, S, N, Syms}
152+
return LArray{Syms}(convert(AbstractArray{T, N}, getfield(x, :__x)))
149153
end
150154
Base.convert(::Type{AbstractArray{T, N}}, x::LArray{T, N}) where {T, N} = x
151155

152-
function ArrayInterface.restructure(x::LArray{T, N, D, Syms},
153-
y::LArray{T2, N2, D2, Syms}) where {T, N, D, T2, N2,
156+
function ArrayInterface.restructure(
157+
x::LArray{T, N, D, Syms},
158+
y::LArray{T2, N2, D2, Syms}
159+
) where {
160+
T, N, D, T2, N2,
154161
D2,
155-
Syms}
156-
reshape(y, size(x)...)
162+
Syms,
163+
}
164+
return reshape(y, size(x)...)
157165
end
158166

159167
#####################################
@@ -162,22 +170,26 @@ end
162170
struct LAStyle{T, N, L} <: Broadcast.AbstractArrayStyle{N} end
163171
LAStyle{T, N, L}(x::Val{i}) where {T, N, L, i} = LAStyle{T, N, L}()
164172
Base.BroadcastStyle(::Type{LArray{T, N, D, L}}) where {T, N, D, L} = LAStyle{T, N, L}()
165-
function Base.BroadcastStyle(::LabelledArrays.LAStyle{T, N, L},
166-
::LabelledArrays.LAStyle{E, N, L}) where {T, E, N, L}
167-
LAStyle{promote_type(T, E), N, L}()
173+
function Base.BroadcastStyle(
174+
::LabelledArrays.LAStyle{T, N, L},
175+
::LabelledArrays.LAStyle{E, N, L}
176+
) where {T, E, N, L}
177+
return LAStyle{promote_type(T, E), N, L}()
168178
end
169179

170180
@generated function labels2axes(::Val{t}) where {t}
171-
if t isa NamedTuple && all(x -> x isa Union{Integer, UnitRange}, values(t)) # range labelling
181+
return if t isa NamedTuple && all(x -> x isa Union{Integer, UnitRange}, values(t)) # range labelling
172182
(Base.OneTo(maximum(Iterators.flatten(v for v in values(t)))),)
173183
elseif t isa NTuple{<:Any, Symbol}
174184
axes(t)
175185
else
176186
error("$t label isn't supported for broadcasting. Try to formulate it in terms of linear indexing.")
177187
end
178188
end
179-
function Base.similar(bc::Broadcast.Broadcasted{LAStyle{T, N, L}},
180-
::Type{ElType}) where {T, N, L, ElType}
189+
function Base.similar(
190+
bc::Broadcast.Broadcasted{LAStyle{T, N, L}},
191+
::Type{ElType}
192+
) where {T, N, L, ElType}
181193
tmp = similar(Array{ElType}, axes(bc))
182194
if axes(bc) != labels2axes(Val(L))
183195
return tmp
@@ -304,7 +316,7 @@ julia> symbols(z)
304316
```
305317
"""
306318
function symbols(::LArray{T, N, D, Syms}) where {T, N, D, Syms}
307-
Syms isa NamedTuple ? keys(Syms) : Syms
319+
return Syms isa NamedTuple ? keys(Syms) : Syms
308320
end
309321

310322
# copy constructors
@@ -321,7 +333,7 @@ For example:
321333
"""
322334
function LVector(v1::Union{SLArray, LArray}; kwargs...)
323335
t2 = merge(convert(NamedTuple, v1), values(kwargs))
324-
LVector(t2)
336+
return LVector(t2)
325337
end
326338

327339
"""
@@ -337,7 +349,7 @@ For example:
337349
"""
338350
function LArray(v1::Union{SLArray, LArray}; kwargs...)
339351
t2 = merge(convert(NamedTuple, v1), values(kwargs))
340-
LArray(size(v1), t2)
352+
return LArray(size(v1), t2)
341353
end
342354

343355
# moved vom slarray.js to here because LArray need to be known
@@ -353,7 +365,7 @@ For example:
353365
"""
354366
function SLVector(v1::Union{SLArray, LArray}; kwargs...)
355367
t2 = merge(convert(NamedTuple, v1), values(kwargs))
356-
SLVector(t2)
368+
return SLVector(t2)
357369
end
358370

359371
"""
@@ -367,26 +379,36 @@ For example:
367379
B = ABCD(1,2,3,4);
368380
B2 = SLArray(B; c=30 )
369381
"""
370-
function SLArray(v1::Union{SLArray{S, T, N, L, Syms}, LArray{T, N, D, Syms}};
371-
kwargs...) where {S, T, N, L, Syms, D}
382+
function SLArray(
383+
v1::Union{SLArray{S, T, N, L, Syms}, LArray{T, N, D, Syms}};
384+
kwargs...
385+
) where {S, T, N, L, Syms, D}
372386
t2 = merge(convert(NamedTuple, v1), values(kwargs))
373-
SLArray{S}(t2)
387+
return SLArray{S}(t2)
374388
end
375389

376390
function Base.vcat(x::LArray, y::LArray)
377-
LArray{(LabelledArrays.symnames(typeof(x))..., LabelledArrays.symnames(typeof(y))...)}(vcat(
378-
x.__x,
379-
y.__x))
391+
return LArray{(LabelledArrays.symnames(typeof(x))..., LabelledArrays.symnames(typeof(y))...)}(
392+
vcat(
393+
x.__x,
394+
y.__x
395+
)
396+
)
380397
end
381398

382399
Base.elsize(::Type{<:LArray{T}}) where {T} = sizeof(T)
383400

384-
function RecursiveArrayTools.recursive_unitless_eltype(a::Type{LArray{
385-
T, N, D, Syms}}) where {
401+
function RecursiveArrayTools.recursive_unitless_eltype(
402+
a::Type{
403+
LArray{
404+
T, N, D, Syms,
405+
},
406+
}
407+
) where {
386408
T,
387409
N,
388410
D,
389-
Syms
390-
}
391-
LArray{typeof(one(T)), N, D, Syms}
411+
Syms,
412+
}
413+
return LArray{typeof(one(T)), N, D, Syms}
392414
end

0 commit comments

Comments
 (0)