-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix is_parameterized() function of controlled gates #13952
base: main
Are you sure you want to change the base?
Conversation
This tests whether gates that take a Parameter argument (or encapsulate such a gate) return True on is_parameterized(). The existing unit test on parameter values skipped all gates after SingletonGate, and reported failure on MCMTGate because it needs a gate argument and a number of target gates instead of floats.
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 following people are relevant to this code:
|
The unit tests found another issue, the controlled gates in This is caused by commit doichanj/qiskit-aer@4587384 (pull request Qiskit/qiskit-aer#1995). I think this should be fixed on the Aer end? |
Some tests still fail as Qiskit/qiskit-aer#2326 is not yet merged. I could change the unit test to test only a fixed list of subclasses, or read the |
To be honest it's not super hacky, in this case I would view the failures as a testing harness bug. The intent of that test is to validate that all the |
Pull Request Test Coverage Report for Build 13856089544Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
I have excluded the classes that start with It only tests classes that are direct subclasses of |
Summary
Controlled gates are not recognised as parameterized by the
is_parameterized()
function. This causes issues in Aer and Algorithms when using circuits with controlled rotations: Qiskit/qiskit-aer#2323, qiskit-community/qiskit-algorithms#216Details and comments
The
is_parameterized()
function reads from the_params
variable, which is not set by some classes that override theparams
property, such asControlledGate
,CUGate
,AnnotatedOperation
andInitialize
.This pull request fixes
is_parameterized()
, such that it reads theparams
variable instead, which corresponds to the parameters of the base gate for controlled gates.This pull request also adds a unit test and fixes an existing one.