Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@

## `draw_circuit(self)`
- **Purpose**: Visualizes the quantum circuit.
- **Usage**: Provides a graphical representation of the quantum circuit for better understanding.
- **Note**: Just a pass through function, will use underlying libraries
method for drawing circuit.
- **Returns**: A string representation of the circuit visualization (format depends on backend).
- **Usage**: Returns a visualization string that can be printed or used programmatically. Example: `print(qc.draw_circuit())` or `viz = qc.draw_circuit()`.
- **Note**: Uses underlying libraries' methods for drawing circuits (Qiskit's `draw()`, Cirq's `str()`, or Braket's `str()`).

## `apply_rx_gate(self, qubit_index, angle)`
- **Purpose**: Applies a rotation around the X-axis to a specified qubit with an optional parameter for optimization.
Expand Down
4 changes: 2 additions & 2 deletions qumat/amazon_braket_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def get_final_state_vector(circuit, backend, backend_config):
def draw_circuit(circuit):
# Unfortunately, Amazon Braket does not have direct support for drawing circuits in the same way
# as Qiskit and Cirq. You would typically visualize Amazon Braket circuits using external tools.
# For simplicity, we'll print the circuit object which gives some textual representation.
print(circuit)
# For simplicity, we'll return the circuit object's string representation.
return str(circuit)


def apply_rx_gate(circuit, qubit_index, angle):
Expand Down
3 changes: 2 additions & 1 deletion qumat/cirq_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def execute_circuit(circuit, backend, backend_config):


def draw_circuit(circuit):
print(circuit)
# Use Cirq's string representation for circuit visualization
return str(circuit)


def apply_rx_gate(circuit, qubit_index, angle):
Expand Down
2 changes: 1 addition & 1 deletion qumat/qiskit_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def get_final_state_vector(circuit, backend, backend_config):

def draw_circuit(circuit):
# Use Qiskit's built-in drawing function
print(circuit.draw())
return circuit.draw()


def apply_rx_gate(circuit, qubit_index, angle):
Expand Down
12 changes: 12 additions & 0 deletions qumat/qumat.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,18 @@ def draw_circuit(self):
self._ensure_circuit_initialized()
return self.backend_module.draw_circuit(self.circuit)

def draw(self):
"""Alias for draw_circuit() for convenience.

Provides a shorter method name that matches common quantum computing
library conventions and documentation examples.

:returns: Circuit visualization. The exact type depends on the backend.
:rtype: str | object
:raises RuntimeError: If the circuit has not been initialized.
"""
return self.draw_circuit()

def apply_rx_gate(self, qubit_index, angle):
"""Apply a rotation around the X-axis to the specified qubit.

Expand Down
2 changes: 1 addition & 1 deletion website/quantum-computing-primer/03_qubits/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ You can also visualize the quantum circuit using the draw method:
qc.draw()
```

This will print a textual representation of the circuit, showing the sequence of gates applied to the qubits.
This returns a textual representation of the circuit, which you can print with `print(qc.draw())` or use programmatically. The visualization shows the sequence of gates applied to the qubits.

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ qc.apply_cnot_gate(0, 1)
qc.draw()
```

This code will print a textual representation of the quantum circuit, showing the sequence of gates applied to the qubits. This visualization helps in understanding the structure of the circuit and the flow of quantum information.
This code returns a textual representation of the quantum circuit, which you can print with `print(qc.draw())` or use programmatically. The visualization shows the sequence of gates applied to the qubits and helps in understanding the structure of the circuit and the flow of quantum information.

## 5.3 Combining Gates to Create Complex Circuits

Expand Down