From ba164b26f66c2ef93cd8557e524324ccd3437f32 Mon Sep 17 00:00:00 2001 From: Tobias Hangleiter <tobias.hangleiter@rwth-aachen.de> Date: Wed, 9 Apr 2025 11:53:37 +0200 Subject: [PATCH] Skip plt output in doctests --- qutil/signal_processing/fourier_space.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/qutil/signal_processing/fourier_space.py b/qutil/signal_processing/fourier_space.py index 9b2b78c..ad51279 100644 --- a/qutil/signal_processing/fourier_space.py +++ b/qutil/signal_processing/fourier_space.py @@ -159,10 +159,10 @@ def derivative(x, f, order: int = 0, overwrite_x: bool = False, >>> import matplotlib.pyplot as plt >>> xfd, f = derivative(xf, f, order=1) >>> xtd = np.gradient(xt, t) - >>> plt.plot(t, 5 * np.cos(5 * t), label='Analytical') - >>> plt.plot(t, xtd, label='Finite differences') - >>> plt.plot(t, np.fft.irfft(xfd, n=n), label='FFT') - >>> plt.legend(); plt.xlabel('$t$'); plt.ylabel('$dx/dt$') + >>> plt.plot(t, 5 * np.cos(5 * t), label='Analytical') # doctest: +SKIP + >>> plt.plot(t, xtd, label='Finite differences') # doctest: +SKIP + >>> plt.plot(t, np.fft.irfft(xfd, n=n), label='FFT') # doctest: +SKIP + >>> plt.legend(); plt.xlabel('$t$'); plt.ylabel('$dx/dt$') # doctest: +SKIP Integrals: @@ -170,10 +170,11 @@ def derivative(x, f, order: int = 0, overwrite_x: bool = False, >>> xfii, f = derivative(xf, f, order=-2) >>> xti = integrate.cumulative_simpson(xt, x=t, initial=0) >>> xtii = integrate.cumulative_simpson(xti, x=t, initial=0) - >>> plt.plot(t, -xt / 25, label='Analytical') - >>> plt.plot(t, xtii - np.linspace(0, 1, n), label='Finite differences') # cheating - >>> plt.plot(t, np.fft.irfft(xfii, n=n), label='FFT') - >>> plt.legend(); plt.xlabel('$t$'); plt.ylabel(r'$\iint x dt$') + >>> plt.plot(t, -xt / 25, label='Analytical') # doctest: +SKIP + >>> # cheating a bit here because indefinite integration is tricky + >>> plt.plot(t, xtii - np.linspace(0, 1, n), label='Finite differences') # doctest: +SKIP + >>> plt.plot(t, np.fft.irfft(xfii, n=n), label='FFT') # doctest: +SKIP + >>> plt.legend(); plt.xlabel('$t$'); plt.ylabel(r'$\iint x dt$') # doctest: +SKIP Note that the backtransform method naturally only works well for periodic data. -- GitLab