Skip to content

Commit a6b893c

Browse files
committed
Fix sympy coefficient typing issue in SymbolicOperator
When adding a new term to a SymbolicOperator with a sympy coefficient, the coefficient was being cast to a float. This was because the default value for a new term was 0.0, which is a float. This commit changes the default value to 0, which is an integer. This ensures that the type of the coefficient is preserved when adding new terms.
1 parent fb7bc39 commit a6b893c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/openfermion/ops/operators/symbolic_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def __iadd__(self, addend):
433433
"""
434434
if isinstance(addend, type(self)):
435435
for term in addend.terms:
436-
self.terms[term] = self.terms.get(term, 0.0) + addend.terms[term]
436+
self.terms[term] = self.terms.get(term, 0) + addend.terms[term]
437437
if self._issmall(self.terms[term]):
438438
del self.terms[term]
439439
elif isinstance(addend, COEFFICIENT_TYPES):

0 commit comments

Comments
 (0)