Skip to content

Commit

Permalink
Merge pull request #450 from rawkintrevo/2209
Browse files Browse the repository at this point in the history
MAHOUT-2209 Implement draw_circuit( method
  • Loading branch information
tdnaugle authored Aug 16, 2024
2 parents 4cede99 + cefbfa9 commit e7d14b4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 7 additions & 1 deletion qumat/amazon_braket_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
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)
2 changes: 2 additions & 0 deletions qumat/cirq_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 4 additions & 0 deletions qumat/qiskit_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
5 changes: 4 additions & 1 deletion qumat/qumat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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)

0 comments on commit e7d14b4

Please sign in to comment.