Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/operators/localoperator/mpo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ function _validate_mpo_term(inds, term::MPOTerm, lattice::AbstractMatrix{<:Eleme
return nothing
end

# TODO: Narrow AbstractVector to MPOTerm once TensorMap's scalar type is restricted to Number.
add_term!(operator::LocalOperator, inds::Tuple, term::AbstractVector) =
add_term!(operator::LocalOperator, inds::Tuple, term::MPOTerm) =
add_term!(operator, collect(inds), term)
add_term!(operator::LocalOperator, inds::AbstractVector, term::AbstractVector) =
add_term!(operator::LocalOperator, inds::AbstractVector, term::MPOTerm) =
add_term!(operator, CartesianIndex{2}[CartesianIndex{2}(ind) for ind in inds], term)
function add_term!(
operator::LocalOperator, inds::Vector{CartesianIndex{2}}, term::AbstractVector
operator::LocalOperator, inds::Vector{CartesianIndex{2}}, term::MPOTerm
)
isempty(term) && throw(ArgumentError("An MPO term should contain at least one tensor."))
term = _promote_term_scalars(term)
Expand Down
1 change: 1 addition & 0 deletions test/testsuite/toolbox/mpo_terms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function toolbox_mpo_bookkeeping(AT)
@test_throws ArgumentError add_term!(deepcopy(left), inds, only(values(right.terms)))
@test_throws ArgumentError left + right
end
@test !applicable(add_term!, mpo_operator, inds, Any[original_mpo...])
@test isempty(LocalOperator(lattice, inds => [zero(first(original_mpo)), last(original_mpo)]).terms)

# Unequal physical spaces expose factor reordering during coordinate transformations.
Expand Down
Loading