Skip to content
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "GradedArrays"
uuid = "bc96ca6e-b7c8-4bb6-888e-c93f838762c2"
version = "0.6.19"
version = "0.6.20"
authors = ["ITensor developers <support@itensor.org> and contributors"]

[workspace]
Expand Down Expand Up @@ -34,7 +34,7 @@ GradedArraysSUNRepresentationsExt = "SUNRepresentations"
[compat]
ArrayLayouts = "1"
BlockArrays = "1.6"
BlockSparseArrays = "0.10"
BlockSparseArrays = "0.10.35"
Compat = "4.16"
FillArrays = "1.13"
HalfIntegers = "1.6"
Expand Down
27 changes: 27 additions & 0 deletions src/sectorarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,22 @@ function Base.similar(
similar(A, elt, kroneckerfactors.(axs, 2))
)
end
# disambiguate for unblocked views of BlockSparseArrays with graded axes
function Base.similar(
A::BlockSparseArrays.UnblockedSubArray,
elt::Type,
axs::Tuple{SectorUnitRange, Vararg{SectorUnitRange}}
)
data_axes = kroneckerfactors.(axs, 2)
data = similar(Array{elt, length(axs)}, data_axes)
for I in CartesianIndices(data)
@inbounds data[I] = A[I]
end
return SectorArray(
kroneckerfactors.(axs, 1),
data
)
end
function Base.similar(
::Type{A},
axs::Tuple{SectorUnitRange, Vararg{SectorUnitRange}}
Expand All @@ -313,6 +329,17 @@ function Base.copy!(C::SectorArray, A::SectorArray)
copy!(arg2(C), arg2(A))
return C
end
function Base.copyto!(dst::SectorArray, src::BlockSparseArrays.UnblockedSubArray)
@invoke copyto!(dst.data::AbstractArray, src::AbstractArray)
return dst
end
function Base.copyto!(
dst::SectorArray,
src::SubArray{<:Any, <:Any, <:BlockSparseArrays.AbstractBlockSparseArray}
)
@invoke copyto!(dst.data::AbstractArray, src::AbstractArray)
return dst
end

function Base.convert(
::Type{SectorArray{T₁, N, I, A}},
Expand Down
3 changes: 0 additions & 3 deletions src/tensoralgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ end

# Sort the blocks by sector and then merge the common sectors.
function sectormergesort(a::AbstractArray)
# TODO: fix this, no clue why broken and no clue how to fix
return a

I = sectormergesortperm.(axes(a))
return a[I...]
end
7 changes: 3 additions & 4 deletions test/test_tensoralgebraext.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ end
@test unmatricize(m, (U1(1), U1(1)), (U1(-2), U1(-1))) isa SectorDelta
end

broken = true

const elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
broken || @testset "`contract` `GradedArray` (eltype=$elt)" for elt in elts
@testset "`contract` `GradedArray` (eltype=$elt)" for elt in elts
@testset "matricize" begin
d1 = gradedrange([U1(0) => 1, U1(1) => 1])
d2 = gradedrange([U1(0) => 1, U1(1) => 1])
Expand Down Expand Up @@ -115,7 +113,8 @@ broken || @testset "`contract` `GradedArray` (eltype=$elt)" for elt in elts
@test a == unmatricize(m, (), (d1, d2, dual(d1), dual(d2)))
end

@testset "contract with U(1)" begin
contract_broken = true
contract_broken || @testset "contract with U(1)" begin
d = gradedrange([U1(0) => 2, U1(1) => 3])
a1 = randn_blockdiagonal(elt, (d, d, dual(d), dual(d)))
a2 = randn_blockdiagonal(elt, (d, d, dual(d), dual(d)))
Expand Down
Loading