Skip to content

Commit c7afab9

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 <noreply@anthropic.com>
1 parent e87de61 commit c7afab9

4 files changed

Lines changed: 60 additions & 38 deletions

File tree

.JuliaFormatter.toml

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

.github/workflows/FormatCheck.yml

Lines changed: 11 additions & 5 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:
6+
- 'master'
67
- 'main'
7-
tags: ['*']
8+
- 'release-'
9+
tags: '*'
810
pull_request:
911

1012
jobs:
11-
format-check:
12-
name: "Format Check"
13-
uses: "SciML/.github/.github/workflows/format-suggestions-on-pr.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'

src/FastAlmostBandedMatrices.jl

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ module FastAlmostBandedMatrices
33
import PrecompileTools: @setup_workload, @compile_workload
44

55
using ArrayInterface, ArrayLayouts, BandedMatrices, ConcreteStructs, LazyArrays,
6-
LinearAlgebra, MatrixFactorizations, Reexport
6+
LinearAlgebra, MatrixFactorizations, Reexport
77

88
import ArrayLayouts: MemoryLayout, sublayout, sub_materialize, MatLdivVec, materialize!,
9-
triangularlayout, triangulardata, zero!, _copyto!, colsupport,
10-
rowsupport, _qr, _qr!, _factorize, muladd!
9+
triangularlayout, triangulardata, zero!, _copyto!, colsupport,
10+
rowsupport, _qr, _qr!, _factorize, muladd!
1111
import BandedMatrices: _banded_qr!, bandeddata, banded_qr_lmul!
1212
import LinearAlgebra: ldiv!
1313
import MatrixFactorizations: QR, QRPackedQ, getQ, getR, QRPackedQLayout, AdjQRPackedQLayout
@@ -24,8 +24,8 @@ import MatrixFactorizations: QR, QRPackedQ, getQ, getR, QRPackedQLayout, AdjQRPa
2424
A lazy representation of the union of two ranges, supporting iteration and indexing
2525
without heap allocation.
2626
"""
27-
struct DisjointRange{T<:Integer, R1<:AbstractUnitRange{T}, R2<:AbstractUnitRange{T}} <:
28-
AbstractVector{T}
27+
struct DisjointRange{T <: Integer, R1 <: AbstractUnitRange{T}, R2 <: AbstractUnitRange{T}} <:
28+
AbstractVector{T}
2929
r1::R1
3030
r2::R2
3131
end
@@ -59,7 +59,7 @@ end
5959

6060
@inline function Base.iterate(d::DisjointRange, state)
6161
which, inner_state = state
62-
if which == 1
62+
return if which == 1
6363
next = iterate(d.r1, inner_state)
6464
if next !== nothing
6565
return next[1], (1, next[2])
@@ -124,28 +124,35 @@ part.
124124
fill
125125
end
126126

127-
function AlmostBandedMatrix(::UndefInitializer, ::Type{T}, mn::NTuple{2, Integer},
128-
lu::NTuple{2, Integer}, rank::Integer) where {T}
127+
function AlmostBandedMatrix(
128+
::UndefInitializer, ::Type{T}, mn::NTuple{2, Integer},
129+
lu::NTuple{2, Integer}, rank::Integer
130+
) where {T}
129131
@assert lu[2] rank - 1
130-
@assert rank1 "Rank 0 fill array makes it a BandedMatrix."
132+
@assert rank 1 "Rank 0 fill array makes it a BandedMatrix."
131133
bands = BandedMatrix{T}(undef, mn, lu)
132134
fill = Matrix{T}(undef, rank, mn[2])
133135
return AlmostBandedMatrix{T}(bands, fill)
134136
end
135137

136-
function AlmostBandedMatrix{T}(::UndefInitializer, mn::NTuple{2, Integer},
137-
lu::NTuple{2, Integer}, rank::Integer) where {T}
138+
function AlmostBandedMatrix{T}(
139+
::UndefInitializer, mn::NTuple{2, Integer},
140+
lu::NTuple{2, Integer}, rank::Integer
141+
) where {T}
138142
return AlmostBandedMatrix(undef, T, mn, lu, rank)
139143
end
140144

141-
function AlmostBandedMatrix(::UndefInitializer, mn::NTuple{2, Integer}, lu::NTuple{
142-
2, Integer}, rank::Integer)
145+
function AlmostBandedMatrix(
146+
::UndefInitializer, mn::NTuple{2, Integer}, lu::NTuple{
147+
2, Integer,
148+
}, rank::Integer
149+
)
143150
return AlmostBandedMatrix(undef, Float64, mn, lu, rank)
144151
end
145152

146153
function AlmostBandedMatrix(bands::BandedMatrix, fill::AbstractMatrix)
147154
@assert size(fill, 2) == size(bands, 2)
148-
@assert size(fill, 1)1 "Rank 0 fill array makes it a BandedMatrix."
155+
@assert size(fill, 1) 1 "Rank 0 fill array makes it a BandedMatrix."
149156
T = promote_type(eltype(fill), eltype(bands))
150157
@assert bandwidths(bands)[1] size(fill, 1) - 1
151158
finish_part_setindex!(bands, fill)
@@ -308,8 +315,13 @@ function LinearAlgebra.triu!(A::AlmostBandedMatrix)
308315
end
309316

310317
# TODO: Support views properly
311-
function sublayout(::AlmostBandedLayout, ::Type{<:Tuple{
312-
AbstractUnitRange{Int}, AbstractUnitRange{Int}}})
318+
function sublayout(
319+
::AlmostBandedLayout, ::Type{
320+
<:Tuple{
321+
AbstractUnitRange{Int}, AbstractUnitRange{Int},
322+
},
323+
}
324+
)
313325
return AlmostBandedLayout()
314326
end
315327

@@ -344,24 +356,26 @@ end
344356
# Pretty Printing
345357
# ---------------
346358
function _almost_banded_summary(io, B::AlmostBandedMatrix{T}, inds) where {T}
347-
print(io, Base.dims2string(length.(inds)),
359+
return print(
360+
io, Base.dims2string(length.(inds)),
348361
" AlmostBandedMatrix{$T} with bandwidths $(almostbandwidths(B)) and fill \
349-
rank $(almostbandedrank(B))")
362+
rank $(almostbandedrank(B))"
363+
)
350364
end
351365
function Base.array_summary(io::IO, B::AlmostBandedMatrix, inds::Tuple{Vararg{Base.OneTo}})
352366
_almost_banded_summary(io, B, inds)
353367
print(io, " with data ")
354368
summary(io, B.bands)
355369
print(io, " and fill ")
356-
summary(io, B.fill)
370+
return summary(io, B.fill)
357371
end
358372
function Base.array_summary(io::IO, B::AlmostBandedMatrix, inds)
359373
_almost_banded_summary(io, B, inds)
360374
print(io, " with data ")
361375
summary(io, B.bands)
362376
print(io, " and fill ")
363377
summary(io, B.fill)
364-
print(io, " with indices ", Base.inds2string(inds))
378+
return print(io, " with indices ", Base.inds2string(inds))
365379
end
366380

367381
# --------------
@@ -370,7 +384,7 @@ end
370384

371385
function ArrayInterface.fast_scalar_indexing(A::AlmostBandedMatrix)
372386
return ArrayInterface.fast_scalar_indexing(typeof(A.bands)) &&
373-
ArrayInterface.fast_scalar_indexing(typeof(A.fill))
387+
ArrayInterface.fast_scalar_indexing(typeof(A.fill))
374388
end
375389

376390
function ArrayInterface.qr_instance(A::AlmostBandedMatrix{T}, pivot = NoPivot()) where {T}
@@ -392,7 +406,8 @@ function _almostbanded_qr(_, A)
392406
# Expand the bandsize for the QR factorization
393407
## Bypass the safety checks in `AlmostBandedMatrix`
394408
return almostbanded_qr!(
395-
AlmostBandedMatrix{eltype(A)}(BandedMatrix(copy(B), (l, l + u)), copy(L)), Val(true))
409+
AlmostBandedMatrix{eltype(A)}(BandedMatrix(copy(B), (l, l + u)), copy(L)), Val(true)
410+
)
396411
end
397412

398413
# Band size not yet expanded!
@@ -445,13 +460,15 @@ end
445460
U′ = U[kr, :]
446461
for j in 1:length(jr2)
447462
muladd!(
448-
-one(T), U′[(j + 1):end, :], L_right[:, j], one(T), B_right[(j + 1):end, j])
463+
-one(T), U′[(j + 1):end, :], L_right[:, j], one(T), B_right[(j + 1):end, j]
464+
)
449465
end
450466
banded_qr_lmul!(Q', B_right)
451467
banded_qr_lmul!(Q', U′)
452468
for j in 1:length(jr2)
453469
muladd!(
454-
one(T), U′[(j + 1):end, :], L_right[:, j], one(T), B_right[(j + 1):end, j])
470+
one(T), U′[(j + 1):end, :], L_right[:, j], one(T), B_right[(j + 1):end, j]
471+
)
455472
end
456473
k = last(jr1) + 1
457474
end
@@ -491,7 +508,7 @@ for Typ in
491508
(:StridedVector, :StridedMatrix, :AbstractVecOrMat, :UpperLayoutMatrix, :LayoutMatrix)
492509
@eval function ldiv!(A::QR{T, <:AlmostBandedMatrix}, B::$Typ{T}) where {T}
493510
m, n = size(A)
494-
if m == n
511+
return if m == n
495512
_almostbanded_square_ldiv!(A, B)
496513
elseif n > m
497514
_almostbanded_widerect_ldiv!(A, B)
@@ -535,7 +552,8 @@ end
535552
@inline __original_almostbandedrank(A) = size(first(__lowrankfillpart(A)), 2)
536553

537554
@views function _almostbanded_upper_ldiv!(
538-
::Type{Tri}, R::AbstractMatrix, b::AbstractVector{T}, buffer) where {T, Tri}
555+
::Type{Tri}, R::AbstractMatrix, b::AbstractVector{T}, buffer
556+
) where {T, Tri}
539557
B = bandpart(R)
540558
U, V = __lowrankfillpart(R)
541559
fill!(buffer, zero(T))
@@ -597,7 +615,8 @@ end
597615
# ---------------
598616

599617
@views function muladd!(
600-
α, A::AlmostBandedMatrix, B::AbstractVecOrMat, β, C::AbstractVecOrMat)
618+
α, A::AlmostBandedMatrix, B::AbstractVecOrMat, β, C::AbstractVecOrMat
619+
)
601620
L = fillpart(A)
602621
muladd!(α, L, B, β, selectdim(C, 1, 1:size(L, 1)))
603622
muladd!(α, exclusive_bandpart(A), B, β, selectdim(C, 1, (size(L, 1) + 1):size(C, 1)))
@@ -628,6 +647,6 @@ end
628647
end
629648

630649
export AlmostBandedMatrix, bandpart, fillpart, exclusive_bandpart, finish_part_setindex!,
631-
almostbandwidths, almostbandedrank
650+
almostbandwidths, almostbandedrank
632651

633652
end

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using SafeTestsets, Test
99
@test A[1, 1] == 2.0
1010
A[4, 1] = 0
1111
@test A[4, 1] == 0.0
12-
@test_throws BandError A[4, 1]=2
12+
@test_throws BandError A[4, 1] = 2
1313
A[1, 3] = 5
1414
@test A[1, 3] == 5.0
1515

@@ -84,7 +84,7 @@ using SafeTestsets, Test
8484
A = AlmostBandedMatrix(BandedMatrix(fill(2.0, n, n), (1, 1)), fill(3.0, 1, n))
8585
b = randn(n)
8686
@test MemoryLayout(UpperTriangular(A)) ==
87-
TriangularLayout{'U', 'N', AlmostBandedLayout}()
87+
TriangularLayout{'U', 'N', AlmostBandedLayout}()
8888
@test_broken UpperTriangular(Matrix(A)) \ b UpperTriangular(A) \ b
8989
@test_broken UnitUpperTriangular(Matrix(A)) \ b UnitUpperTriangular(A) \ b
9090
@test LowerTriangular(Matrix(A)) \ b LowerTriangular(A) \ b

0 commit comments

Comments
 (0)