diff --git a/docs/api.md b/docs/api.md index d87b8fe00..82ae5a918 100644 --- a/docs/api.md +++ b/docs/api.md @@ -67,3 +67,9 @@ ## `execute_circuit(self)` - **Purpose**: Executes the quantum circuit and retrieves the results. - **Usage**: Used to run the entire set of quantum operations and measure the outcomes. + +## `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. \ No newline at end of file diff --git a/qumat/amazon_braket_backend.py b/qumat/amazon_braket_backend.py index ad1b04a75..bddeae790 100644 --- a/qumat/amazon_braket_backend.py +++ b/qumat/amazon_braket_backend.py @@ -61,4 +61,10 @@ def execute_circuit(circuit, backend, backend_config): # placeholder method for use in the testing suite def get_final_state_vector(circuit, backend, backend_config): - raise NotImplementedError("Final state vector calculation is not currently supported with Amazon Braket.") \ No newline at end of file + raise NotImplementedError("Final state vector calculation is not currently supported with Amazon Braket.") + +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) \ No newline at end of file diff --git a/qumat/cirq_backend.py b/qumat/cirq_backend.py index 597ceb7fd..056b302e6 100644 --- a/qumat/cirq_backend.py +++ b/qumat/cirq_backend.py @@ -71,3 +71,5 @@ def execute_circuit(circuit, backend, backend_config): result = simulator.run(circuit, repetitions=backend_config['backend_options'].get('shots', 1)) return result.histogram(key='result') +def draw_circuit(circuit): + print(circuit) \ No newline at end of file diff --git a/qumat/qiskit_backend.py b/qumat/qiskit_backend.py index ffa12ca0a..c8324dcf8 100644 --- a/qumat/qiskit_backend.py +++ b/qumat/qiskit_backend.py @@ -86,3 +86,7 @@ def get_final_state_vector(circuit, backend, backend_config): result = job.result() return result.get_statevector() + +def draw_circuit(circuit): + # Use Qiskit's built-in drawing function + print(circuit.draw()) \ No newline at end of file diff --git a/qumat/qumat.py b/qumat/qumat.py index 5d6f7a25c..dd5b03eb6 100644 --- a/qumat/qumat.py +++ b/qumat/qumat.py @@ -57,4 +57,7 @@ def execute_circuit(self): # placeholder method for use in the testing suite def get_final_state_vector(self): - return self.backend_module.get_final_state_vector(self.circuit, self.backend, self.backend_config) \ No newline at end of file + return self.backend_module.get_final_state_vector(self.circuit, self.backend, self.backend_config) + + def draw(self): + return self.backend_module.draw_circuit(self.circuit) \ No newline at end of file