From 81a837f6653492e50745a6464c0ca18b4399be37 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Sat, 12 Apr 2025 00:49:36 +0000 Subject: [PATCH 1/2] Format .jl files --- Project.toml | 2 +- docs/make.jl | 7 ++----- .../blocksparsearrayinterface.jl | 15 +++++++++------ src/factorizations/svd.jl | 3 ++- test/runtests.jl | 6 ++++-- test/test_basics.jl | 8 ++++---- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Project.toml b/Project.toml index deb59649..f81c9055 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BlockSparseArrays" uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4" authors = ["ITensor developers and contributors"] -version = "0.4.3" +version = "0.4.4" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/docs/make.jl b/docs/make.jl index 8b38fc1f..49b91db6 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,13 +2,10 @@ using BlockSparseArrays: BlockSparseArrays using Documenter: Documenter, DocMeta, deploydocs, makedocs DocMeta.setdocmeta!( - BlockSparseArrays, - :DocTestSetup, - quote + BlockSparseArrays, :DocTestSetup, quote using BlockSparseArrays using LinearAlgebra: Diagonal - end; - recursive=true, + end; recursive=true ) include("make_index.jl") diff --git a/src/blocksparsearrayinterface/blocksparsearrayinterface.jl b/src/blocksparsearrayinterface/blocksparsearrayinterface.jl index e258af84..1b1af5f5 100644 --- a/src/blocksparsearrayinterface/blocksparsearrayinterface.jl +++ b/src/blocksparsearrayinterface/blocksparsearrayinterface.jl @@ -97,8 +97,9 @@ end struct BlockSparseArrayInterface <: AbstractBlockSparseArrayInterface end -@interface ::AbstractBlockSparseArrayInterface BlockArrays.blocks(a::AbstractArray) = - error("Not implemented") +@interface ::AbstractBlockSparseArrayInterface BlockArrays.blocks(a::AbstractArray) = error( + "Not implemented" +) @interface ::AbstractBlockSparseArrayInterface function SparseArraysBase.isstored( a::AbstractArray{<:Any,N}, I::Vararg{Int,N} @@ -336,10 +337,12 @@ end reverse_index(index) = reverse(index) reverse_index(index::CartesianIndex) = CartesianIndex(reverse(Tuple(index))) -@interface ::AbstractBlockSparseArrayInterface BlockArrays.blocks(a::Transpose) = - transpose(blocks(parent(a))) -@interface ::AbstractBlockSparseArrayInterface BlockArrays.blocks(a::Adjoint) = - adjoint(blocks(parent(a))) +@interface ::AbstractBlockSparseArrayInterface BlockArrays.blocks(a::Transpose) = transpose( + blocks(parent(a)) +) +@interface ::AbstractBlockSparseArrayInterface BlockArrays.blocks(a::Adjoint) = adjoint( + blocks(parent(a)) +) # Represents the array of arrays of a `SubArray` # wrapping a block spare array, i.e. `blocks(array)` where `a` is a `SubArray`. diff --git a/src/factorizations/svd.jl b/src/factorizations/svd.jl index 3c82f23a..1cdcda50 100644 --- a/src/factorizations/svd.jl +++ b/src/factorizations/svd.jl @@ -197,8 +197,9 @@ julia> Uonly == U true ``` """ -svd(A; kwargs...) = +function svd(A; kwargs...) SVD(svd!(eigencopy_oftype(A, LinearAlgebra.eigtype(eltype(A))); kwargs...)) +end LinearAlgebra.svdvals(usv::SVD{<:Any,T}) where {T} = (usv.S)::AbstractVector{T} diff --git a/test/runtests.jl b/test/runtests.jl index 1c52c3e1..b4ae80fa 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -14,11 +14,13 @@ const GROUP = uppercase( ) "match files of the form `test_*.jl`, but exclude `*setup*.jl`" -istestfile(fn) = +function istestfile(fn) endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup") +end "match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`" -isexamplefile(fn) = +function isexamplefile(fn) endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup") +end @time begin # tests in groups based on folder structure diff --git a/test/test_basics.jl b/test/test_basics.jl index ee87ddc9..61225286 100644 --- a/test/test_basics.jl +++ b/test/test_basics.jl @@ -242,11 +242,11 @@ arrayts = (Array, JLArray) @test Array(a) isa Array{elt,0} @test Array(a) == fill(0) for b in ( - (b = copy(a); @allowscalar(b[] = 2); b), - (b = copy(a); @allowscalar(b[CartesianIndex()] = 2); b), - (b = copy(a); @allowscalar(b[Block()[]] = 2); b), + (b=copy(a); @allowscalar(b[] = 2); b), + (b=copy(a); @allowscalar(b[CartesianIndex()] = 2); b), + (b=copy(a); @allowscalar(b[Block()[]] = 2); b), # Regression test for https://github.com/ITensor/BlockSparseArrays.jl/issues/27. - (b = copy(a); b[Block()] = dev(fill(2)); b), + (b=copy(a); b[Block()]=dev(fill(2)); b), ) @test size(b) == () @test isone(length(b)) From 25ee61a2d968cb6d2e74f3d1e1b950c04b7dc6a0 Mon Sep 17 00:00:00 2001 From: Matt Fishman Date: Sat, 12 Apr 2025 08:55:18 -0400 Subject: [PATCH 2/2] Apply suggestions from code review --- src/factorizations/svd.jl | 2 +- test/runtests.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/factorizations/svd.jl b/src/factorizations/svd.jl index 1cdcda50..f25a50c2 100644 --- a/src/factorizations/svd.jl +++ b/src/factorizations/svd.jl @@ -198,7 +198,7 @@ true ``` """ function svd(A; kwargs...) - SVD(svd!(eigencopy_oftype(A, LinearAlgebra.eigtype(eltype(A))); kwargs...)) + return SVD(svd!(eigencopy_oftype(A, LinearAlgebra.eigtype(eltype(A))); kwargs...)) end LinearAlgebra.svdvals(usv::SVD{<:Any,T}) where {T} = (usv.S)::AbstractVector{T} diff --git a/test/runtests.jl b/test/runtests.jl index b4ae80fa..98b2d2b8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,11 +15,11 @@ const GROUP = uppercase( "match files of the form `test_*.jl`, but exclude `*setup*.jl`" function istestfile(fn) - endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup") + return endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup") end "match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`" function isexamplefile(fn) - endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup") + return endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup") end @time begin