Esempio n. 1
0
 def test_plot_circuit_layout(self, backend):
     """ tests plot_circuit_layout for each device"""
     layout_length = int(backend._configuration.n_qubits / 2)
     qr = QuantumRegister(layout_length, 'qr')
     circuit = QuantumCircuit(qr)
     circuit._layout = Layout({qr[i]: i * 2 for i in range(layout_length)})
     n = backend.configuration().n_qubits
     img_ref = path_to_diagram_reference(str(n) + "_plot_circuit_layout.png")
     filename = str(n) + "_plot_circuit_layout_result.png"
     fig = plot_circuit_layout(circuit, backend)
     fig.savefig(filename)
     self.assertImagesAreEqual(filename, img_ref, 0.1)
     os.remove(filename)
 def test_plot_circuit_layout(self, backend):
     """tests plot_circuit_layout for each device"""
     layout_length = int(backend._configuration.n_qubits / 2)
     qr = QuantumRegister(layout_length, "qr")
     circuit = QuantumCircuit(qr)
     circuit._layout = Layout({qr[i]: i * 2 for i in range(layout_length)})
     circuit._layout.add_register(qr)
     n = backend.configuration().n_qubits
     img_ref = path_to_diagram_reference(str(n) + "_plot_circuit_layout.png")
     fig = plot_circuit_layout(circuit, backend)
     with BytesIO() as img_buffer:
         fig.savefig(img_buffer, format="png")
         img_buffer.seek(0)
         self.assertImagesAreEqual(Image.open(img_buffer), img_ref, 0.1)
     plt.close(fig)