OS: lubuntu 20.04 Mozilla Firefox browser jupyter-lab environment
Error message: AttributeError: 'QuantumCircuit' object has no attribute 'save_unitary'
Below is the code:
from qiskit import QuantumCircuit, Aer, assemble
from math import pi
import numpy as np
from qiskit.visualization import plot_bloch_multivector, plot_histogram, array_to_latex
import matplotlib.pyplot as plt
def show_figure(fig):
# create a dummy figure and use its
# manager to display "fig"
dummy = plt.figure()
#print("plt.figure is set")
new_manager = dummy.canvas.manager
#print("canvas.manager assigned")
new_manager.canvas.figure = fig
fig.set_canvas(new_manager.canvas)
qc = QuantumCircuit(2)
qc.x(0)
qc.x(1)
qc.h(0)
qc.h(1)
qc.cx(0,1)
qc.h(0)
qc.h(1)
display(qc.draw(initial_state=True, output='mpl'))
plt.show()
print(qc)
qc.save_unitary()
usim = Aer.get_backend("aer_simulator")
qobj = assemble(qc)
unitary = usim.run(qobj).result().get_unitary()
#array_to_latex(unitary, prefix="\\text{Circuit}\n")
```