Last active
April 2, 2018 14:30
-
-
Save eddieschoute/9586c4a4734764e35492602cf1c3f030 to your computer and use it in GitHub Desktop.
Gate hierarchy for qiskit
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
class Gate: | |
def apply(self, circuit: BaseQuantumCircuit) -> None | |
def qasm(self) -> String | |
class InvertibleGate(Gate): | |
def inverse(self) -> InvertibleGate | |
class HGate(InvertibleGate): | |
implementation... | |
class CNotGate(InvertibleGate): | |
etc... | |
class HGateMixin(BaseQuantumCircuit): | |
def h(self, params): | |
gate = HGate(...) # Construct hgate | |
gate.apply(self) # Apply hgate. The types add up since self inherits from BaseQuantumCircuit | |
class CNotMixin: | |
etc... | |
class StandardGateMixins(HGateMixin, CNotMixin, ...(all standard gate-mixins)): | |
"""Repackage all standard mixins into one for exporting.""" | |
class QuantumCircuit(StandardGateMixins): | |
"""Would want to inherit from BaseQuantumCircuit and StandardGateMixins for clarity but cannot, | |
because of multiple inheritance conflict. | |
Still, QuantumCircuit inherits from BaseQuantumCircuit through the mixins.""" | |
implementation... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment