-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add singleton lookup-key logic (#11040)
* Add singleton lookup-key logic This adds overridable logic for singleton classes to define a "key" function, which takes the same arguments as its `__init__` and returns a lookup key that is used as a comparison for returning singletons. This lets the standard singleton gates easily return the singleton instance even when `label` is explicitly set to the default, such as happens using the idiomatic `QuantumCircuit` methods like `x`. This keying logic has a simple logical extension to allow more than one singleton to exist for a single base class. This functionality is not yet used by the Qiskit standard library, but can easily be used to make both closed- and open-controlled versions of gates singletons, or to allow specific hard-coded parameters for (e.g.) `RZGate` singletons. The decision on which gates to extend this to can be done in follow-up commits later. * Fix unnecessary statement * 🇺🇸 Co-authored-by: Matthew Treinish <[email protected]> * Update documentation comments --------- Co-authored-by: Matthew Treinish <[email protected]>
- Loading branch information
1 parent
976d765
commit a881215
Showing
15 changed files
with
558 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.