From f7942a8960a6cfd915668768a791847fa783257e Mon Sep 17 00:00:00 2001 From: William Galvin Date: Tue, 26 Dec 2023 17:43:40 -0800 Subject: [PATCH] Fix output dir creation --- pennylane/vqe_pennylane/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pennylane/vqe_pennylane/main.py b/pennylane/vqe_pennylane/main.py index 6774bff..c5d010f 100644 --- a/pennylane/vqe_pennylane/main.py +++ b/pennylane/vqe_pennylane/main.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import argparse +import os from pennylane import numpy as np import numpy @@ -108,6 +109,9 @@ def cost_fn(param): plt.xticks(fontsize=12) plt.yticks(fontsize=12) + if not os.path.exists(args.output_dir): + os.makedirs(args.output_dir) + plt.savefig(f"{args.output_dir}/plot.png") print(f"\nPlot saved at {args.output_dir}/plot.png")