Skip to content

Commit d97bb1f

Browse files
authored
ITensorFormatter (#100)
1 parent 326c9c7 commit d97bb1f

30 files changed

Lines changed: 204 additions & 190 deletions

.github/workflows/IntegrationTest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
paths:
99
- 'Project.toml'
1010
pull_request:
11+
types: [opened, synchronize, reopened, ready_for_review, converted_to_draft]
1112
paths:
1213
- 'Project.toml'
1314

.github/workflows/Tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
paths-ignore:
1010
- 'docs/**'
1111
pull_request:
12+
types: [opened, synchronize, reopened, ready_for_review, converted_to_draft]
1213
workflow_dispatch:
1314

1415
concurrency:

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "SparseArraysBase"
22
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
3-
version = "0.9.2"
3+
version = "0.9.3"
44
authors = ["ITensor developers <support@itensor.org> and contributors"]
55

66
[workspace]

README.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,9 @@ julia> Pkg.add("SparseArraysBase")
4242
## Examples
4343

4444
````julia
45-
using SparseArraysBase:
46-
SparseArrayDOK,
47-
SparseMatrixDOK,
48-
SparseVectorDOK,
49-
eachstoredindex,
50-
getstoredindex,
51-
getunstoredindex,
52-
isstored,
53-
setstoredindex!,
54-
setunstoredindex!,
55-
storedlength,
56-
storedpairs,
57-
storedvalues,
58-
zero!
45+
using SparseArraysBase: SparseArrayDOK, SparseMatrixDOK, SparseVectorDOK, eachstoredindex,
46+
getstoredindex, getunstoredindex, isstored, setstoredindex!, setunstoredindex!,
47+
storedlength, storedpairs, storedvalues, zero!
5948
using Test: @test, @test_throws
6049

6150
a = SparseArrayDOK{Float64}(undef, 2, 2)

benchmark/benchmarks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using SparseArraysBase
21
using BenchmarkTools
2+
using SparseArraysBase
33

44
SUITE = BenchmarkGroup()
55
SUITE["rand"] = @benchmarkable rand(10)

docs/make.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using SparseArraysBase: SparseArraysBase
21
using Documenter: Documenter, DocMeta, deploydocs, makedocs
2+
using SparseArraysBase: SparseArraysBase
33

44
DocMeta.setdocmeta!(
5-
SparseArraysBase, :DocTestSetup, :(using SparseArraysBase); recursive = true
5+
SparseArraysBase, :DocTestSetup, :(using SparseArraysBase); recursive = true,
66
)
77

88
include("make_index.jl")
@@ -20,5 +20,5 @@ makedocs(;
2020
)
2121

2222
deploydocs(;
23-
repo = "github.com/ITensor/SparseArraysBase.jl", devbranch = "main", push_preview = true
23+
repo = "github.com/ITensor/SparseArraysBase.jl", devbranch = "main", push_preview = true,
2424
)

examples/README.jl

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,9 @@ julia> Pkg.add("SparseArraysBase")
4343

4444
# ## Examples
4545

46-
using SparseArraysBase:
47-
SparseArrayDOK,
48-
SparseMatrixDOK,
49-
SparseVectorDOK,
50-
eachstoredindex,
51-
getstoredindex,
52-
getunstoredindex,
53-
isstored,
54-
setstoredindex!,
55-
setunstoredindex!,
56-
storedlength,
57-
storedpairs,
58-
storedvalues,
59-
zero!
46+
using SparseArraysBase: SparseArrayDOK, SparseMatrixDOK, SparseVectorDOK, eachstoredindex,
47+
getstoredindex, getunstoredindex, isstored, setstoredindex!, setunstoredindex!,
48+
storedlength, storedpairs, storedvalues, zero!
6049
using Test: @test, @test_throws
6150

6251
a = SparseArrayDOK{Float64}(undef, 2, 2)

ext/SparseArraysBaseNamedDimsArraysExt/SparseArraysBaseNamedDimsArraysExt.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module SparseArraysBaseNamedDimsArraysExt
22

3-
using NamedDimsArrays: AbstractNamedDimsArray, AbstractNamedUnitRange, denamed, inds,
4-
name, nameddims, nameddimsof
3+
using NamedDimsArrays: AbstractNamedDimsArray, AbstractNamedUnitRange, denamed, inds, name,
4+
nameddims, nameddimsof
55
using SparseArraysBase: SparseArraysBase, dense, oneelement
66

77
function SparseArraysBase.dense(a::AbstractNamedDimsArray)
@@ -11,7 +11,7 @@ function SparseArraysBase.dense(a::AbstractNamedDimsArray)
1111
end
1212

1313
function SparseArraysBase.oneelement(
14-
value, index::NTuple{N, Int}, ax::NTuple{N, AbstractNamedUnitRange}
14+
value, index::NTuple{N, Int}, ax::NTuple{N, AbstractNamedUnitRange},
1515
) where {N}
1616
return nameddims(oneelement(value, index, denamed.(ax)), name.(ax))
1717
end

ext/SparseArraysBaseTensorAlgebraExt/SparseArraysBaseTensorAlgebraExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct SparseArrayFusion <: FusionStyle end
99
TensorAlgebra.FusionStyle(::Type{<:AnyAbstractSparseArray}) = SparseArrayFusion()
1010

1111
function TensorAlgebra.matricize(
12-
style::SparseArrayFusion, a::AbstractArray, length_codomain::Val
12+
style::SparseArrayFusion, a::AbstractArray, length_codomain::Val,
1313
)
1414
m = matricize(ReshapeFusion(), a, length_codomain)
1515
return convert(SparseMatrixCSC, m)

src/abstractsparsearray.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ const AnyAbstractSparseVecOrMat{T} = Union{
2424
Base.convert(T::Type{<:AbstractSparseArray}, a::AbstractArray) = a isa T ? a : T(a)
2525

2626
using FunctionImplementations: FunctionImplementations
27-
FunctionImplementations.ImplementationStyle(::Type{<:AnyAbstractSparseArray}) =
28-
SparseArrayImplementationStyle()
27+
function FunctionImplementations.ImplementationStyle(::Type{<:AnyAbstractSparseArray})
28+
return SparseArrayImplementationStyle()
29+
end
2930

3031
function Base.copy(a::AnyAbstractSparseArray)
3132
return copyto!(similar(a), a)
@@ -51,7 +52,7 @@ function Base.similar(a::AnyAbstractSparseArray, T::Type, ax::Tuple{Vararg{Int}}
5152
return similar_sparsearray(a, T, ax)
5253
end
5354
function Base.similar(
54-
a::AnyAbstractSparseArray, T::Type, ax::Tuple{Integer, Vararg{Integer}}
55+
a::AnyAbstractSparseArray, T::Type, ax::Tuple{Integer, Vararg{Integer}},
5556
)
5657
return similar_sparsearray(a, T, ax)
5758
end
@@ -145,7 +146,7 @@ function Base.print_array(io::IO, a::AnyAbstractSparseArray)
145146
return @invoke Base.print_array(io::typeof(io), a′::AbstractArray{<:Any, ndims(a)})
146147
end
147148
function Base.replace_in_print_matrix(
148-
a::AnyAbstractSparseVecOrMat, i::Integer, j::Integer, s::AbstractString
149+
a::AnyAbstractSparseVecOrMat, i::Integer, j::Integer, s::AbstractString,
149150
)
150151
return isstored(a, i, j) ? s : Base.replace_with_centered_mark(s)
151152
end
@@ -261,7 +262,7 @@ See also [`sparserand`](@ref).
261262

262263
sparserand!(A::AbstractArray; kwargs...) = sparserand!(default_rng(), A; kwargs...)
263264
function sparserand!(
264-
rng::AbstractRNG, A::AbstractArray; density::Real = 0.5, randfun::Function = Random.rand
265+
rng::AbstractRNG, A::AbstractArray; density::Real = 0.5, randfun::Function = Random.rand,
265266
)
266267
ArrayLayouts.zero!(A)
267268
rand_inds = Random.randsubseq(rng, eachindex(A), density)
@@ -273,10 +274,14 @@ end
273274

274275
using ArrayLayouts: ArrayLayouts, MemoryLayout
275276
using LinearAlgebra: LinearAlgebra, Adjoint
276-
function ArrayLayouts.MemoryLayout(::Type{Transpose{T, P}}) where {T, P <: AbstractSparseMatrix}
277+
function ArrayLayouts.MemoryLayout(
278+
::Type{Transpose{T, P}},
279+
) where {T, P <: AbstractSparseMatrix}
277280
return MemoryLayout(P)
278281
end
279-
function ArrayLayouts.MemoryLayout(::Type{Adjoint{T, P}}) where {T, P <: AbstractSparseMatrix}
282+
function ArrayLayouts.MemoryLayout(
283+
::Type{Adjoint{T, P}},
284+
) where {T, P <: AbstractSparseMatrix}
280285
return MemoryLayout(P)
281286
end
282287
function LinearAlgebra.mul!(

0 commit comments

Comments
 (0)