fixed wrong time value in Trotterized Unitary #8126#9388
Conversation
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
| ti = Parameter("t") | ||
| u2 = Suzuki(1, order=1).convert(ti * ham) | ||
| u2_t = u2.bind_parameters({ti: time}) | ||
| self.assertEqual(u2_t, u1) |
There was a problem hiding this comment.
In addition to asserting the operators are equal, add an assertion that explicitly ensures that the coefficient is 11 and not 121.
There was a problem hiding this comment.
I will add the expliceit assertion.
|
|
||
| if isinstance(operator.coeff, (float, ParameterExpression)): | ||
| coeff = operator.coeff | ||
| if not isinstance(coeff, float): |
There was a problem hiding this comment.
A positive condition is clearer than a negative condition:
if isinstance(coeff, ParameterExpression):There was a problem hiding this comment.
I got a DeprecationWarning: The class qiskit.opflow.evolutions.trotterizations.suzuki.Suzuki is deprecatied as of qiskit-terra 0.24.0. I propose to add this condition in the Suzuki class in opflow, however this will only be a temporary aprovement because the opflow class is deprecated. In thw future PauliEvolutionGate could be used.
|
With the removal of opflow in #11111, this PR is now obsolete. Thanks for the effort at the time, and sorry we weren't able to move it merge before opflow was removed. |
Summary
fixes #8126
Details and comments
Fix wrong time value in Trotterized unitary #8126.
When Computing a suzuki decomposition of a Hamiltonian for a given time t, if t is a float, everything works fine.
If t is a Parameter object the value gets squared when it is bound.
This is tested with function test_suzuki_trotterization_time_parameter(self).