Fix extraction of controlled parametric gates (backport #13067) #13080
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The
mutable
check in the controlled-gateOperationFromPython
extraction logic to check for a mutatedbase_gate
was overzealous, and would return false positives for parametric controlled gates. The only modification tobase_gate
of a standard-library gate that would not have caused data-model problems from Python space would be setting the base-gate label, which is used for a public feature of the circuit visualisers.The change to
get_standard_gate_name_mapping
is just a minor convenience to make the gate objects directly appendable to a circuit; previously, eachParameter
object was distinct and had a UUID clash with others of the same name, so could not be used together. The new behaviour is purely a convenience for tests; it largely should not be useful for users to directly append these gates.Details and comments
This is an automatic backport of pull request #13067 done by [Mergify](https://mergify.com).