Skip to content

Conversation

mhucka
Copy link
Contributor

@mhucka mhucka commented Aug 25, 2025

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.

mhucka added 4 commits August 25, 2025 10:56
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.
@mhucka mhucka marked this pull request as ready for review August 25, 2025 18:32
@mhucka mhucka added the area/health Involves code and/or project health label Aug 25, 2025
Comment on lines 15 to 22
import copy
import numpy
import sympy
import unittest
import warnings

import numpy
import sympy
from openfermion.config import EQ_TOLERANCE
from openfermion.testing.testing_utils import EqualsTester
Copy link
Contributor

@pavoljuhas pavoljuhas Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The imports are usually grouped in 3 alphabetically sorted blocks: (1) builtin imports (2) third_party imports (3) current package imports.

Can you please put back the numpy, sympy imports after builtins?

Same in the test module above.

Copy link
Contributor

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please restore the import order per inline comment.

As pointed out by @pavoljuhas in the review comments, the ordering did
not follow conventions. I ran the files through `isort` this time, to try
to fix the ordering.
@mhucka
Copy link
Contributor Author

mhucka commented Aug 26, 2025

LGTM, but please restore the import order per inline comment.

Yeah, I had done it by hand (the pylint setup for this project needs to be updated and doesn't help in this case) and predictably, I got it wrong.

I ran the files through isort. @pavoljuhas Hopefully they're correct now?

@mhucka mhucka added this pull request to the merge queue Aug 27, 2025
Merged via the queue into master with commit 53fc7de Aug 27, 2025
30 checks passed
@mhucka mhucka deleted the mh-fix-885 branch August 27, 2025 20:38
mhucka added a commit that referenced this pull request Sep 1, 2025
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.
mhucka added a commit that referenced this pull request Sep 1, 2025
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.
mhucka added a commit to mhucka/OpenFermion that referenced this pull request Sep 25, 2025
…alue (quantumlib#1112)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/health Involves code and/or project health

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants