Skip to content

Deprecate duplicate circuit gate method #10797

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

Merged
merged 14 commits into from
Sep 29, 2023

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Sep 8, 2023

Summary

Currently, several gates can be appended to the circuit with two differently named methods. As "circuit maintenance" and cleanup we would like to keep only a single way of doing this task. This PR deprecates duplicate quantum circuit gate methods to deprecate and remove them in following releases.

Details and comments

The methods that are kept are the ones aligned with the gate naming scheme. For example, the identity gate is called CXGate and not CnotGate, therefore the plan is to remove QuantumCircuit.cnot and only keep the exisiting QuantumCircuit.cx. Note that this PR does not add any new methods but only removes duplicates.

The deprecations are:

  • i -> id (this is the only exception: the gate is called IGate but id was voted to be more intuitive, and IGate might go away in the future)
  • cnot -> cx
  • toffoli -> ccx
  • mct -> mcx
  • fredkin -> cswap

No reno is added as nothing is deprecated yet.

@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

@Cryoris Cryoris added this to the 0.45.0 milestone Sep 8, 2023
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we shouldn't just make this a full deprecation now? It seems to me there isn't anything really to wait on before deprecating the aliases.

Also, the only one I'm questioning here is QuantumCircuit.id, tbh I don't think I've ever used the i method for an identity gate. It's a bit different too because wasn't it the proper method in the past?

@Cryoris
Copy link
Contributor Author

Cryoris commented Sep 11, 2023

True, the new path exists and we can just deprecate them 👍🏻

I was going for i for consistency, but it's true that a method called i might not be what users expect when looking for an "identity". It might be worth breaking the consistency here in favor of useability 🙂

@Cryoris Cryoris changed the title Pending-deprecate duplicate circuit gate method Deprecate duplicate circuit gate method Sep 22, 2023
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty straightforwards, thanks. Still needs a deprecation release note before it can be merged.

@Cryoris
Copy link
Contributor Author

Cryoris commented Sep 29, 2023

Added in 58ad6f2 👍🏻

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@jakelishman jakelishman added this pull request to the merge queue Sep 29, 2023
Merged via the queue into Qiskit:main with commit a4ca0ca Sep 29, 2023
@Cryoris Cryoris deleted the deprecate-duplicates branch October 6, 2023 12:37
rupeshknn pushed a commit to rupeshknn/qiskit that referenced this pull request Oct 9, 2023
* Pending-deprecate duplicate circuit methods

* Missed some old methods

* may darkness rule (aka "run black")

* Deprecate and id not i

* use id over i

* capture Aer's usage of QuantumCircuit.i

* catch warning, don't assert

* try fix errors

Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>

* Attempt 2 of ?

Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>

* Attempt 3 of 3 (hopefully)

* redundant "+"

* Filter the deprecation warning globally

* add reno

---------

Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
@ElePT ElePT added the Changelog: Deprecation Include in "Deprecated" section of changelog label Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Deprecation Include in "Deprecated" section of changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants