[ITensors] Fix OpSum issue when a site operator has no blocks #1165
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
There was a bug in the QN version of OpSum where if one of the site operators making up a term had no blocks (was exactly zero), then the logic of figuring out which block of the column index which was based on finding the operator's flux, could break. (I.e. the intended operator might have a non-zero flux, but if it has no blocks, the
flux
function returnsnothing
. This can happen when the operator is something like "C*C" which goes outside the local Hilbert space.)This fix checks for the
nnzblocks(Op)==0
case and just skips such operators.Fixes #1150
If practical and applicable, please include a minimal demonstration of the previous behavior and new behavior below.
Minimal demonstration of previous behavior
See #1150 for a minimal example code that throws an exception.
How Has This Been Tested?
Added a new "regression test" to the
test_autompo.jl
file.Checklist:
using JuliaFormatter; format(".")
in the base directory of the repository (~/.julia/dev/ITensors
) to format your code according to our style guidelines.