mdevaluate/test/test_utils.py
Sebastian Kloth 16233e2f2c Merge branch 'mdeval_dev'
# Conflicts:
#	.gitignore
#	doc/conf.py
#	examples/plot_chi4.py
#	examples/plot_isf.py
#	examples/plot_spatialisf.py
#	examples/plot_temperature.py
#	src/mdevaluate/cli.py
#	src/mdevaluate/correlation.py
#	src/mdevaluate/distribution.py
#	src/mdevaluate/functions.py
#	test/test_atoms.py
2024-01-16 16:54:54 +01:00

34 lines
916 B
Python

from copy import copy
import pytest
import numpy as np
from mdevaluate import utils
@pytest.fixture
def logdata(request):
xdata = np.logspace(-1, 3, 50)
ydata = np.exp(-((xdata) ** 0.7))
return xdata, ydata
def test_filon_fourier_transformation(logdata):
xdata, ydata = logdata
xdata_zero = copy(xdata)
xdata_zero[0] = 0
_, filon = utils.filon_fourier_transformation(xdata_zero, ydata)
assert not np.isnan(filon).any(), "There are NaN values in the filon result!"
freqs = np.logspace(-4, 1)
filon_freqs, filon_imag = utils.filon_fourier_transformation(
xdata, xdata, frequencies=freqs, derivative="linear", imag=True
)
assert (freqs == filon_freqs).all()
freqs, filon_real = utils.filon_fourier_transformation(
xdata, xdata, frequencies=freqs, derivative="linear", imag=False
)
assert np.isclose(filon_imag.real, filon_real).all()