Skip to content
Snippets Groups Projects
Verified Commit ba164b26 authored by Tobias Hangleiter's avatar Tobias Hangleiter
Browse files

Skip plt output in doctests

parent 19b572fe
No related branches found
No related tags found
1 merge request!175Add missing imaginary unit in fourier_space.derivative
...@@ -159,10 +159,10 @@ def derivative(x, f, order: int = 0, overwrite_x: bool = False, ...@@ -159,10 +159,10 @@ def derivative(x, f, order: int = 0, overwrite_x: bool = False,
>>> import matplotlib.pyplot as plt >>> import matplotlib.pyplot as plt
>>> xfd, f = derivative(xf, f, order=1) >>> xfd, f = derivative(xf, f, order=1)
>>> xtd = np.gradient(xt, t) >>> xtd = np.gradient(xt, t)
>>> plt.plot(t, 5 * np.cos(5 * t), label='Analytical') >>> plt.plot(t, 5 * np.cos(5 * t), label='Analytical') # doctest: +SKIP
>>> plt.plot(t, xtd, label='Finite differences') >>> plt.plot(t, xtd, label='Finite differences') # doctest: +SKIP
>>> plt.plot(t, np.fft.irfft(xfd, n=n), label='FFT') >>> plt.plot(t, np.fft.irfft(xfd, n=n), label='FFT') # doctest: +SKIP
>>> plt.legend(); plt.xlabel('$t$'); plt.ylabel('$dx/dt$') >>> plt.legend(); plt.xlabel('$t$'); plt.ylabel('$dx/dt$') # doctest: +SKIP
Integrals: Integrals:
...@@ -170,10 +170,11 @@ def derivative(x, f, order: int = 0, overwrite_x: bool = False, ...@@ -170,10 +170,11 @@ def derivative(x, f, order: int = 0, overwrite_x: bool = False,
>>> xfii, f = derivative(xf, f, order=-2) >>> xfii, f = derivative(xf, f, order=-2)
>>> xti = integrate.cumulative_simpson(xt, x=t, initial=0) >>> xti = integrate.cumulative_simpson(xt, x=t, initial=0)
>>> xtii = integrate.cumulative_simpson(xti, x=t, initial=0) >>> xtii = integrate.cumulative_simpson(xti, x=t, initial=0)
>>> plt.plot(t, -xt / 25, label='Analytical') >>> plt.plot(t, -xt / 25, label='Analytical') # doctest: +SKIP
>>> plt.plot(t, xtii - np.linspace(0, 1, n), label='Finite differences') # cheating >>> # cheating a bit here because indefinite integration is tricky
>>> plt.plot(t, np.fft.irfft(xfii, n=n), label='FFT') >>> plt.plot(t, xtii - np.linspace(0, 1, n), label='Finite differences') # doctest: +SKIP
>>> plt.legend(); plt.xlabel('$t$'); plt.ylabel(r'$\iint x dt$') >>> 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 Note that the backtransform method naturally only works well for
periodic data. periodic data.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment