From 6cfe52a2dbe3de3339b26a2f6125320a324f1a35 Mon Sep 17 00:00:00 2001 From: JoshuaLau0220 Date: Tue, 6 Jun 2023 20:47:02 +0800 Subject: [PATCH 1/3] Fix QuantumCircuit.draw() not outputting pdf in latex mode --- qiskit/visualization/circuit/circuit_visualization.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qiskit/visualization/circuit/circuit_visualization.py b/qiskit/visualization/circuit/circuit_visualization.py index 0627f2617063..271c61a9c334 100644 --- a/qiskit/visualization/circuit/circuit_visualization.py +++ b/qiskit/visualization/circuit/circuit_visualization.py @@ -495,7 +495,8 @@ def _latex_circuit_drawer( image = trim_image(image) if filename: if filename.endswith(".pdf"): - os.rename(base + ".pdf", filename) + import shutil + shutil.move(base + ".pdf", filename) else: try: image.save(filename) From fb80d077585c390a3d85dcdfd380934dd5993d21 Mon Sep 17 00:00:00 2001 From: JoshuaLau0220 Date: Tue, 6 Jun 2023 21:17:23 +0800 Subject: [PATCH 2/3] Added bugfix release note; moved import to the top --- qiskit/visualization/circuit/circuit_visualization.py | 2 +- ...the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml diff --git a/qiskit/visualization/circuit/circuit_visualization.py b/qiskit/visualization/circuit/circuit_visualization.py index 271c61a9c334..ebdffca002a2 100644 --- a/qiskit/visualization/circuit/circuit_visualization.py +++ b/qiskit/visualization/circuit/circuit_visualization.py @@ -28,6 +28,7 @@ import os import subprocess import tempfile +import shutil from warnings import warn from qiskit import user_config @@ -495,7 +496,6 @@ def _latex_circuit_drawer( image = trim_image(image) if filename: if filename.endswith(".pdf"): - import shutil shutil.move(base + ".pdf", filename) else: try: diff --git a/releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml b/releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml new file mode 100644 index 000000000000..855ad9eb0858 --- /dev/null +++ b/releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml @@ -0,0 +1,6 @@ + +fixes: + - | + Fixed regression in the LaTeX drawer of `QuantumCircuit`. + See `#10211 `__ + From 8609b0bb7a6232ff6e8b238edabac89cc3308b2f Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Tue, 6 Jun 2023 15:33:37 +0100 Subject: [PATCH 3/3] Fixup release note --- ...the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml b/releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml index 855ad9eb0858..fdeec4027e2c 100644 --- a/releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml +++ b/releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml @@ -1,6 +1,8 @@ fixes: - | - Fixed regression in the LaTeX drawer of `QuantumCircuit`. - See `#10211 `__ + Fixed a regression in the LaTeX drawer of :meth:`.QuantumCircuit.draw` + when temporary files are placed on a separate filesystem to the working + directory. See + `#10211 `__.