-
Notifications
You must be signed in to change notification settings - Fork 401
Fix #885: type coercion due to slightly incorrect default value #1112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
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 |
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.
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.
…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.
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 was0.0
, which is a float. This commit changes the default value to0
, which is an integer. This ensures that the type of the coefficient is preserved when adding new terms.