Consistent naming of the standard gates#3695
Conversation
|
For the deprecation warnings we could have two mechanisms (and probably also others). or we could derive the old class from the new one, to still give access to something of the old-class type: Latter seems safer to me, since we still have the old class available as type. Is there another standard procedure to deprecate class names? |
|
The overall approach looks good. For the deprecation, we should think through what cases we want to cover, because I agree handling it in full generality wouldn't be straightforward. While the second example supports It might be beneficial to split this in two PRs. One to rename and deprecate the to-be-renamed classes, and another to update all the instances where they are used. |
That's correct, but this instance-checking is not really something we expect anybody to do, or is it? |
|
To pass @kdk's check you may be able to define a metaclass like ... |
ewinston
left a comment
There was a problem hiding this comment.
Overall looks good. Some comments I have;
- Since this PR has many user facing changes could you add deprecations to the release notes. The procedure for this is described in "CONTRIBUTING.md".
- In some gate classes you prepended "The" to the docstring. I think I prefer without but it's probably more in line with PEP8 to have a complete sentence. It just could be more consistent.
|
Edit: The up-to-date list is in the description of this PR. Updating @kdk's list from #3633, the gate names are now |
|
I noticed that the gates in |
|
@Cryoris I think I've seen diagonal gate being used by people, so yeah it would be good to deprecate those too. |
|
@ajavadia I added the previous classes with a deprecation warning. Also I added a test to
|
|
Thanks for this effort! |
* rename the gates according to terra issue Qiskit#3633 * fix typos, quotes * replace gate names in qiskit and test dirs * replace qc.iden by qc.i * fix lint, and some leftover renamings * add matrix representation of CY * UCG -> UCGate and .ucg -> uc * UC(X,Y,Z) -> UCR(X,Y,Z)Gate and uc(x,y,z) -> ucr(x,y,z) * fix line length * fix lint * add deprecation warnings for old classes * fix missing theta arg * fix test, test type via subclass not "== type" * add reno changelog for the gate names * rename UCRot -> UCPauliRotGate * rename ucrot file, fix line len * rename Sdg -> Sinv, sdg -> sinv * fix metaclass instancecheck using isinstance() as required by pylint caused unterminated recursive call of instancecheck * fix parser test sinv is one char longer than sdg, thus the parsed commands are longer (3 appearances, therefore 3 chars longer) * rename Tdg -> Tinv, tdg -> tinv * fix text drawer test * update to non-deprecated qc methods * test.python.test_qasm_parser.TestParser.test_parser * support both *dg/*inv in qelib1.inc * *dg must remain standard extensions in AstInterpreter * name: ucrot(X,Y,Z) -> ucr(x,y,z), fix (doc)strings along the way * add test on all qelib1.inc gates * fix *inv -> *Inv naming * fix missing renamings, use all_gates.qasm instead of a str * correct gate label for sinv/tinv * start renaming "id" -> "i" * rename all id -> i * reno: fix typos, update gate list * add i gate to qasm * deprecation warnings adhere to contribution guidelines * fix id json keyword * fix modified png file * remove obsolete if case * set deprecation version to 0.12.0 * revert changes on backend configs * keep sdg,tdg,id as valid aliases * revert names to id/sdg/tdg * update error message error message on "i" changed back to "id" * avoid cyclic imports * rename the method diag_gate to diag, update reno * add comment why Initialize is not unitary * change deprecation version to 0.14.0 * fix lints, rename diag -> diagonal * fix deprecation on import * fix Cnot/CX naming * fix deprecation version * fix return of multiplexer pauli rotations * name swap uppercase throughout * rename iso -> isometry (keep alias) * Update deprecation warning Co-Authored-By: Luciano Bello <luciano.bello@ibm.com> * Update deprecation warning of ucx Co-Authored-By: Luciano Bello <luciano.bello@ibm.com> * Update deprecation warning of ucz Co-Authored-By: Luciano Bello <luciano.bello@ibm.com> * Update deprecation warning of ucy Co-Authored-By: Luciano Bello <luciano.bello@ibm.com> * fix redefine outer scope * attempt fixing jupyter cells * move matrix repr from Fredkin to CSwap * add reno * Revert "move matrix repr from Fredkin to CSwap" This reverts commit cd13878. * Revert "add reno" This reverts commit f1be570. * unrevert revert * fix leftover Cnot * keep old quantum initializer classes but deprecate * fix lint & test * add test for the deprecated classes Co-authored-by: Luciano Bello <luciano.bello@ibm.com> Co-authored-by: ewinston <ewinston@us.ibm.com> Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Summary
Ensure consistent naming of the standard gates according to #3633
Details and comments
This PR ensures that the names of the standard gates follow the same consistent principles. See #3633 for more detail and the discussion on gate naming. The old/current gates will be deprecated.
Up-to-date list of the names:
Gate checklist:
QuantumCircuitmethod aliases in renosNote:
MCGupDiagis left as is, this refactor will be tackled via #3761.