-
Notifications
You must be signed in to change notification settings - Fork 401
QubitOperator term simplification #480
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
The three failing tests are
defined in
All three are due to
We're trying to connect to pubchem.ncbi.nlm.nih.gov. This looks like a temporary error or a configuration issue. I ran the tests locally a few times and they succeed:
Triggered a re-run on travis. |
One(*) of the three tests failed again, the other two succeeded. (*) ExamplesTest.test_can_run_examples_jupyter_notebooks |
All tests passed on re-run. Filed #481 about the flakiness. Coverage loss is a single line in QubitOperator's |
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, thanks!
@viathor thanks for this pull request. Note that the issue you were running into with that code calling the pubchem website has come up many times before. If you have any reasonable solutions, perhaps even removing the tests for that completely, it would be quite helpful actually. |
OK, grabbed the issue I filed yesterday, #481 and will look into it once I have a moment. I don't think we need to remove the tests, it's probably just a matter of making a local copy of the dataset that is being downloaded. |
Fixes #446.
Note that QubitOperator has already been capable of simplifying terms before this PR. However, the old algorithm was implemented in an override for
__imul__()
and therefore was not executed on initialization. There was also the trivial simplification logic (sorting by index) for operators that commute for different indices which was executed in the two parsing functions.This PR moves the trivial simplification logic into its own function
_simplify()
in SymbolicOperator and ensures it is called after initialization and multiplication. It also adds an override in QubitOperator that performs the simplifications described in #446. Finally, it removes the now unnecessary override for__imul__()
in QubitOperator.This affects BosonOperator since it commutes across different indices. Hence the need to update unit tests.
The PR also adds unit tests for the simplification logic.