-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Moving up some parameter checks in the class hierarchy #3668
Conversation
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.
Looks good, one question is whether or not the base Instruction
class should default permissive or default restrictive. Default permissive is less likely to break existing users as it matches previous behavior, but maybe its the case that substantially more gates would have to specify that they e.g. don't accept complex parameters. Alternately, subclasses could be annotated with the types they support. Thoughts?
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.
I'm a bit confused here. Like we're moving the type checking for each parameter in params()
to a normalize_parameters
method so subclasses can override it and define their own behavior, that makes sense to me. But, none of the subclasses look like they do anything different because we call the parent's method if it's not one of the expected types for the subclass.
57854df adds |
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.
Based on a discussion offline we decided that for the base Instruction class they should accept anything and it's on the users to not manually set a parameter type that can't be handled by the whatever the output mechanism of the circuit is. With that open question settled this PR LGTM.
…t#3668)" This change has some unforseen backwards compatibility implications and is causing downstream projects like qiskit-aer to fail CI now. Given the pending release and this not being critical, this commit reverts this commit and we can revisit it after the 0.13.0 release. This reverts commit 5afe87c.
…" (#4117) This change has some unforseen backwards compatibility implications and is causing downstream projects like qiskit-aer to fail CI now. Given the pending release and this not being critical, this commit reverts this commit and we can revisit it after the 0.13.0 release. This reverts commit 5afe87c.
…t#3668)" (Qiskit#4117) This change has some unforseen backwards compatibility implications and is causing downstream projects like qiskit-aer to fail CI now. Given the pending release and this not being critical, this commit reverts this commit and we can revisit it after the 0.13.0 release. This reverts commit 5afe87c. add new fake backends
…4129) * Revert "Moving up some parameter checks in the class hierarchy (#3668)" (#4117) This change has some unforseen backwards compatibility implications and is causing downstream projects like qiskit-aer to fail CI now. Given the pending release and this not being critical, this commit reverts this commit and we can revisit it after the 0.13.0 release. This reverts commit 5afe87c. add new fake backends * fix dt and dtm conversion by qiskit to SI * fix imports * lint * Update qiskit/test/mock/backends/armonk/fake_armonk.py Co-Authored-By: Kevin Krsulich <[email protected]> Co-authored-by: Matthew Treinish <[email protected]> Co-authored-by: Kevin Krsulich <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* abstract method * moving some checks up the Class hierarchy * lint * lint! * normalize_parameter * merge * instruction * no need to override in gate * clean qiskit/extensions/quantum_initializer/diag.py diff * new approach * mising import * validate_parameter * skip multiplexer * docstring * lint * deprecation warning * custom gates are gates * add np.number for gate parameters * lint * barrier validate_parameter * syntax error * message * test barrier * no warning * unused import Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…t#3668)" (Qiskit#4117) This change has some unforseen backwards compatibility implications and is causing downstream projects like qiskit-aer to fail CI now. Given the pending release and this not being critical, this commit reverts this commit and we can revisit it after the 0.13.0 release. This reverts commit 5afe87c.
…iskit#4129) * Revert "Moving up some parameter checks in the class hierarchy (Qiskit#3668)" (Qiskit#4117) This change has some unforseen backwards compatibility implications and is causing downstream projects like qiskit-aer to fail CI now. Given the pending release and this not being critical, this commit reverts this commit and we can revisit it after the 0.13.0 release. This reverts commit 5afe87c. add new fake backends * fix dt and dtm conversion by qiskit to SI * fix imports * lint * Update qiskit/test/mock/backends/armonk/fake_armonk.py Co-Authored-By: Kevin Krsulich <[email protected]> Co-authored-by: Matthew Treinish <[email protected]> Co-authored-by: Kevin Krsulich <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…iskit/qiskit#4129) * Revert "Moving up some parameter checks in the class hierarchy (Qiskit/qiskit#3668)" (Qiskit/qiskit#4117) This change has some unforseen backwards compatibility implications and is causing downstream projects like qiskit-aer to fail CI now. Given the pending release and this not being critical, this commit reverts this commit and we can revisit it after the 0.13.0 release. This reverts commit 5afe87ce1e5279ca716fdf5a3c478f2e27a6519f. add new fake backends * fix dt and dtm conversion by qiskit to SI * fix imports * lint * Update qiskit/test/mock/backends/armonk/fake_armonk.py Co-Authored-By: Kevin Krsulich <[email protected]> Co-authored-by: Matthew Treinish <[email protected]> Co-authored-by: Kevin Krsulich <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fixes #3282
@nonhermitian notices that parameters are too broadly checked. I moved some of the checks up the class hierarchy. This allows to be more prices in the kind of check and normalization for each class. Also, it can be improved further with a better class hierarchy for
Instructions
. But that's story for another time.All the tests are passing. If reviewers find a uncovered case, let's add the test!