Skip to content

Commit accd88a

Browse files
Automatic JuliaFormatter.jl run (#55)
Co-authored-by: mtfishman <[email protected]>
1 parent 0e4a532 commit accd88a

File tree

4 files changed

+57
-43
lines changed

4 files changed

+57
-43
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseArraysBase"
22
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.5.5"
4+
version = "0.5.6"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

src/indexing.jl

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ Obtain `getindex(A, I...)` with the guarantee that there is a stored entry at th
1212
1313
Similar to `Base.getindex`, new definitions should be in line with `IndexStyle(A)`.
1414
"""
15-
@inline getstoredindex(A::AbstractArray, I...) =
16-
@interface interface(A) getstoredindex(A, I...)
15+
@inline getstoredindex(A::AbstractArray, I...) = @interface interface(A) getstoredindex(
16+
A, I...
17+
)
1718

1819
"""
1920
getunstoredindex(A::AbstractArray, I...) -> eltype(A)
@@ -25,8 +26,9 @@ instantiated object.
2526
2627
Similar to `Base.getindex`, new definitions should be in line with `IndexStyle(A)`.
2728
"""
28-
@inline getunstoredindex(A::AbstractArray, I...) =
29-
@interface interface(A) getunstoredindex(A, I...)
29+
@inline getunstoredindex(A::AbstractArray, I...) = @interface interface(A) getunstoredindex(
30+
A, I...
31+
)
3032

3133
"""
3234
isstored(A::AbstractArray, I...) -> Bool
@@ -46,8 +48,9 @@ Similar to `Base.getindex`, new definitions should be in line with `IndexStyle(A
4648
4749
Similar to `Base.setindex!`, new definitions should be in line with `IndexStyle(A)`.
4850
"""
49-
@inline setstoredindex!(A::AbstractArray, v, I...) =
50-
@interface interface(A) setstoredindex!(A, v, I...)
51+
@inline setstoredindex!(A::AbstractArray, v, I...) = @interface interface(A) setstoredindex!(
52+
A, v, I...
53+
)
5154

5255
"""
5356
setunstoredindex!(A::AbstractArray, v, I...) -> A
@@ -56,8 +59,9 @@ Similar to `Base.setindex!`, new definitions should be in line with `IndexStyle(
5659
5760
Similar to `Base.setindex!`, new definitions should be in line with `IndexStyle(A)`.
5861
"""
59-
@inline setunstoredindex!(A::AbstractArray, v, I...) =
60-
@interface interface(A) setunstoredindex!(A, v, I...)
62+
@inline setunstoredindex!(A::AbstractArray, v, I...) = @interface interface(A) setunstoredindex!(
63+
A, v, I...
64+
)
6165

6266
# Indices interface
6367
# -----------------
@@ -150,14 +154,16 @@ for f in (:isstored, :getunstoredindex, :getstoredindex)
150154
end
151155

152156
# errors
153-
$_f(::IndexStyle, A::AbstractArray, I...) =
154-
error("`$f` for $("$(typeof(A))") with types $("$(typeof(I))") is not supported")
155-
156-
$error_if_canonical(::IndexLinear, A::AbstractArray, ::Int) =
157-
throw(Base.CanonicalIndexError("$($f)", typeof(A)))
158-
$error_if_canonical(
159-
::IndexCartesian, A::AbstractArray{<:Any,N}, ::Vararg{Int,N}
160-
) where {N} = throw(Base.CanonicalIndexError("$($f)", typeof(A)))
157+
$_f(::IndexStyle, A::AbstractArray, I...) = error(
158+
"`$f` for $("$(typeof(A))") with types $("$(typeof(I))") is not supported"
159+
)
160+
161+
$error_if_canonical(::IndexLinear, A::AbstractArray, ::Int) = throw(
162+
Base.CanonicalIndexError("$($f)", typeof(A))
163+
)
164+
$error_if_canonical(::IndexCartesian, A::AbstractArray{<:Any,N}, ::Vararg{Int,N}) where {N} = throw(
165+
Base.CanonicalIndexError("$($f)", typeof(A))
166+
)
161167
$error_if_canonical(::IndexStyle, A::AbstractArray, ::Any...) = nothing
162168
end
163169
end
@@ -193,14 +199,16 @@ for f! in (:setunstoredindex!, :setstoredindex!)
193199
end
194200

195201
# errors
196-
$_f!(::IndexStyle, A::AbstractArray, I...) =
197-
error("`$f!` for $("$(typeof(A))") with types $("$(typeof(I))") is not supported")
198-
199-
$error_if_canonical(::IndexLinear, A::AbstractArray, ::Int) =
200-
throw(Base.CanonicalIndexError("$($(string(f!)))", typeof(A)))
201-
$error_if_canonical(
202-
::IndexCartesian, A::AbstractArray{<:Any,N}, ::Vararg{Int,N}
203-
) where {N} = throw(Base.CanonicalIndexError("$($f!)", typeof(A)))
202+
$_f!(::IndexStyle, A::AbstractArray, I...) = error(
203+
"`$f!` for $("$(typeof(A))") with types $("$(typeof(I))") is not supported"
204+
)
205+
206+
$error_if_canonical(::IndexLinear, A::AbstractArray, ::Int) = throw(
207+
Base.CanonicalIndexError("$($(string(f!)))", typeof(A))
208+
)
209+
$error_if_canonical(::IndexCartesian, A::AbstractArray{<:Any,N}, ::Vararg{Int,N}) where {N} = throw(
210+
Base.CanonicalIndexError("$($f!)", typeof(A))
211+
)
204212
$error_if_canonical(::IndexStyle, A::AbstractArray, ::Any...) = nothing
205213
end
206214
end
@@ -227,14 +235,16 @@ end
227235
@inline
228236
return setindex!(A, v, I...)
229237
end
230-
@interface ::AbstractArrayInterface setunstoredindex!(A::AbstractArray, v, I::Int...) =
231-
error("setunstoredindex! for $(typeof(A)) is not supported")
238+
@interface ::AbstractArrayInterface setunstoredindex!(A::AbstractArray, v, I::Int...) = error(
239+
"setunstoredindex! for $(typeof(A)) is not supported"
240+
)
232241

233-
@interface ::AbstractArrayInterface eachstoredindex(A::AbstractArray, B::AbstractArray...) =
234-
eachstoredindex(IndexStyle(A, B...), A, B...)
235-
@interface ::AbstractArrayInterface eachstoredindex(
236-
style::IndexStyle, A::AbstractArray, B::AbstractArray...
237-
) = eachindex(style, A, B...)
242+
@interface ::AbstractArrayInterface eachstoredindex(A::AbstractArray, B::AbstractArray...) = eachstoredindex(
243+
IndexStyle(A, B...), A, B...
244+
)
245+
@interface ::AbstractArrayInterface eachstoredindex(style::IndexStyle, A::AbstractArray, B::AbstractArray...) = eachindex(
246+
style, A, B...
247+
)
238248

239249
@interface ::AbstractArrayInterface storedvalues(A::AbstractArray) = values(A)
240250
@interface ::AbstractArrayInterface storedpairs(A::AbstractArray) = pairs(A)
@@ -299,9 +309,9 @@ end
299309
end
300310

301311
# required:
302-
@interface ::AbstractSparseArrayInterface eachstoredindex(
303-
style::IndexStyle, A::AbstractArray
304-
) = throw(MethodError(eachstoredindex, Tuple{typeof(style),typeof(A)}))
312+
@interface ::AbstractSparseArrayInterface eachstoredindex(style::IndexStyle, A::AbstractArray) = throw(
313+
MethodError(eachstoredindex, Tuple{typeof(style),typeof(A)})
314+
)
305315

306316
# derived but may be specialized:
307317
@interface ::AbstractSparseArrayInterface function eachstoredindex(
@@ -379,8 +389,9 @@ for f! in (:setstoredindex!, :setunstoredindex!)
379389
end
380390
end
381391

382-
@interface ::AbstractSparseArrayInterface storedlength(A::AbstractArray) =
383-
length(storedvalues(A))
392+
@interface ::AbstractSparseArrayInterface storedlength(A::AbstractArray) = length(
393+
storedvalues(A)
394+
)
384395
@interface ::AbstractSparseArrayInterface function storedpairs(A::AbstractArray)
385396
return Iterators.map(I -> (I => A[I]), eachstoredindex(A))
386397
end

src/wrappers.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ else
201201
return view(CartesianIndices(x), LinearAlgebra.diagind(x))
202202
end
203203
end
204-
@interface ::AbstractArrayInterface eachstoredindex(D::Diagonal) =
205-
_diagind(D, IndexCartesian())
204+
@interface ::AbstractArrayInterface eachstoredindex(D::Diagonal) = _diagind(
205+
D, IndexCartesian()
206+
)
206207

207208
@interface ::AbstractArrayInterface function isstored(D::Diagonal, i::Int, j::Int)
208209
return i == j && checkbounds(Bool, D, i, j)

test/runtests.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ const GROUP = uppercase(
1414
)
1515

1616
"match files of the form `test_*.jl`, but exclude `*setup*.jl`"
17-
istestfile(fn) =
18-
endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
17+
function istestfile(fn)
18+
return endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
19+
end
1920
"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`"
20-
isexamplefile(fn) =
21-
endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")
21+
function isexamplefile(fn)
22+
return endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")
23+
end
2224

2325
@time begin
2426
# tests in groups based on folder structure

0 commit comments

Comments
 (0)