When indexed sum are nested through Sum involve a KroneckerDelta the scalar_indexed_sum_over_kronecker does not know how to handle it.
>>> i = IdxSym('i'); j = IdxSym('j')
>>> ket_i = BasisKet(FockIndex(i), hs=0)
>>> ket_j = BasisKet(FockIndex(j), hs=0)
>>> Sum(i)(Sum(j)(ket_i.dag() * ket_j))
Traceback (most recent call last):
File "<ipython-input-6-11142b06b2d0>", line 1, in <module>
Sum(i)(Sum(j)(ket_i.dag() * ket_j))
File "/Users/goerz/Documents/Programming/github/QNET/src/qnet/algebra/core/abstract_quantum_algebra.py", line 776, in sum
return term._indexed_sum_cls.create(term, idx_range)
File "/Users/goerz/Documents/Programming/github/QNET/src/qnet/algebra/core/scalar_algebra.py", line 861, in create
return super().create(term, *ranges)
File "/Users/goerz/Documents/Programming/github/QNET/src/qnet/algebra/core/abstract_algebra.py", line 115, in create
simplified = simplification(cls, args, kwargs)
File "/Users/goerz/Documents/Programming/github/QNET/src/qnet/algebra/core/algebraic_properties.py", line 558, in scalar_indexed_sum_over_kronecker
assert i in bound_symbols and j in bound_symbols
AssertionError
The solution is to handle the case where only one of i, j is an index of the sum (the sum can still be executed, so this is an easy fix). Once this is done, test_sum_instantiator can be updated to test this case.
When indexed sum are nested through
Sum
involve aKroneckerDelta
thescalar_indexed_sum_over_kronecker
does not know how to handle it.The solution is to handle the case where only one of
i
,j
is an index of the sum (the sum can still be executed, so this is an easy fix). Once this is done,test_sum_instantiator
can be updated to test this case.