Skip to content

Commit

Permalink
[ITensor] Make checkflux pass for dense ITensors (#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
emstoudenmire authored Dec 11, 2023
1 parent a5ee0d5 commit a00ef70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/qn/flux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ allfluxequal(T::Tensor) = allequal(flux(T, b) for b in nzblocks(T))
Check that fluxes of all non-zero blocks of a blocked or symmetric Tensor
are equal. Throws an error if one or more blocks have a different flux.
If the tensor is dense (is not blocked) then `checkflux` returns `nothing`.
"""
checkflux(T::Tensor) = allfluxequal(T) ? nothing : error("Fluxes not all equal")
function checkflux(T::Tensor)
(!hasqns(T) || isempty(T)) && return nothing
return allfluxequal(T) ? nothing : error("Fluxes not all equal")
end

"""
checkflux(T::Tensor, flux)
Expand Down
5 changes: 5 additions & 0 deletions test/base/test_itensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,11 @@ end
n = uniqueindex(N, A)
@test dim(n) == dim(j) - dim(i)
end

@testset "checkflux test" begin
# Calling checkflux should not error (issue #1283)
@test ITensors.checkflux(randomITensor(Index(2))) == nothing
end
end # End Dense ITensor basic functionality

# Disable debug checking once tests are completed
Expand Down

0 comments on commit a00ef70

Please sign in to comment.