Skip to content
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

add drawer #61

Merged
merged 5 commits into from
Aug 25, 2024
Merged

add drawer #61

merged 5 commits into from
Aug 25, 2024

Conversation

Jacomichi
Copy link
Collaborator

Change

I created a circuitry drawer.
You need to include matplotlib in the dependencies.

Example

from qamomile.core.circuit.drawer import plot_quantum_circuit

def create_vqe_circuit(n_qubits: int, depth: int) -> QuantumCircuit:
    """Create a circuit mimicking a part of Variational Quantum Eigensolver."""
    qc = QuantumCircuit(n_qubits,n_qubits, name="VQE-like Circuit")
    for d in range(depth):
        for i in range(n_qubits):
            qc.ry(Parameter(f'θ_{d},{i}'), i)
            qc.rz(Parameter(f'φ_{d},{i}'), i)
        for i in range(n_qubits - 1):
            qc.cnot(i, i+1)
        qc.cnot(n_qubits-1, 0)
    for i in range(n_qubits):
        qc.measure(i, i)
    return qc

vqe_circuit = create_vqe_circuit(5, 3)
plot_quantum_circuit(vqe_circuit)

e3ac4906-540c-4f2f-9b57-50a75fb44cc6

@Jacomichi Jacomichi requested a review from yuyamashiro August 23, 2024 12:39
@yuyamashiro
Copy link
Contributor

The draw function is not a core feature for running quantum calculations, so I am a bit hesitant to add matplotlib as a dependency. For example, Qiskit does not include matplotlib as a dependency, and it requires users to explicitly install it when using the draw function.

However, I think it’s acceptable for now to include it as a dependency and address any issues that arise later. Let’s go with that approach.

@yuyamashiro
Copy link
Contributor

  • I added the ability to draw the Operator class.
  • Introduced the decompose_level argument, allowing operators grouped within the Operator class to be decomposed and represented.
  • Added variable labels to the QuantumCircuit class, which are now used when drawing.
  • In the case of QAOA, I made it possible to associate with classical bits, making the display more intuitive.
  • Refactored the drawer module and added comments.

@yuyamashiro yuyamashiro merged commit 0385560 into main Aug 25, 2024
6 checks passed
@yuyamashiro yuyamashiro deleted the feature/drawer branch August 25, 2024 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants