Skip to content

Commit

Permalink
use plt.show for the general parameter shift demo (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
antalszava committed Dec 8, 2021
1 parent 4d327d1 commit e2af147
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions demonstrations/tutorial_general_parshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def cost(x):
ax.set_xlabel("$x$")

_ = axs[0].set_ylabel("$E$")
plt.show()


###############################################################################
Expand Down Expand Up @@ -278,6 +279,7 @@ def cost(x):
_ = [axs[j, i].set_ylabel(lab) for j, lab in enumerate(["$a_\ell/2$", "$b_\ell/2$"])]
else:
_ = [axs[j, i].set_ylabel("") for j in [0, 1]]
plt.show()


###############################################################################
Expand Down Expand Up @@ -407,6 +409,7 @@ def compare_functions(originals, reconstructions, Ns, shifts, show_diff=True):

equ_shifts = [[2 * mu * np.pi / (2 * N + 1) for mu in range(-N, N + 1)] for N in Ns]
fig, axs = compare_functions(cost_functions, reconstructions_equ, Ns, equ_shifts)
plt.show()


###############################################################################
Expand Down Expand Up @@ -485,6 +488,7 @@ def reconstruction(x):
shifts = [rnd.random(2 * N + 1) * 2 * np.pi - np.pi for N in Ns]
reconstructions_gen = list(map(full_reconstruction_gen, cost_functions, shifts))
fig, axs = compare_functions(cost_functions, reconstructions_gen, Ns, shifts)
plt.show()


###############################################################################
Expand Down Expand Up @@ -694,6 +698,7 @@ def reconstruction(x):
handles = [Line2D([0], [0], color=c, ls=ls, lw=1.2) for c, ls in zip(colors, styles)]
labels = ['Original', 'Odd reconstruction', 'Even reconstruction', 'Summed reconstruction']
_ = fig.legend(handles, labels, bbox_to_anchor=(0.2, 0.89), loc='lower left', ncol=4)
plt.show()


###############################################################################
Expand Down

0 comments on commit e2af147

Please sign in to comment.