Adjusted tests

This commit is contained in:
Sebastian Kloth 2024-01-10 12:41:18 +01:00
parent ba893881a3
commit 9e9c865cf9
2 changed files with 34 additions and 47 deletions

View File

@ -4,7 +4,7 @@ import pytest
import numpy as np import numpy as np
import mdevaluate import mdevaluate
from mdevaluate import free_energy_landscape as fel import mdevaluate.extra.free_energy_landscape as fel
@pytest.fixture @pytest.fixture
@ -15,40 +15,40 @@ def trajectory(request):
def test_get_fel(trajectory): def test_get_fel(trajectory):
test_array = np.array( test_array = np.array(
[ [
0.0, 174.46253634,
12.87438176, 174.60905476,
4.95868203, 178.57658092,
11.02055197, 182.43001192,
5.44195534, 180.57916378,
6.73933442, 176.49886217,
3.30971789, 178.96018547,
6.10424055, 181.13561782,
8.56153733, 178.31026314,
5.45777331, 176.08903996,
5.64545817, 180.71215345,
8.42100423, 181.59703135,
6.28132121, 180.34329368,
7.4777172, 187.02474488,
11.64839354, 197.99167477,
4.52566354, 214.05788031,
40.84730838, 245.58571282,
93.86241602, 287.52457507,
140.3039937, 331.53492965,
173.55970021,
] ]
) )
oxygens_water = trajectory.subset(atom_name="OW", residue_name="SOL") OW = trajectory.subset(atom_name="OW")
r, energy_differences = fel.get_fel(
oxygens_water,
os.path.join(os.path.dirname(__file__), "data/pore"),
"cylindrical",
225,
edge=0.05,
radiusmin=0.05,
radiusmax=2.05,
z=[-np.inf, np.inf],
overwrite=True,
)
assert (np.round(energy_differences) == np.round(test_array)).all() box = np.diag(trajectory[0].box)
box_voxels = (box // [0.05, 0.05, 0.05] + [1, 1, 1]) * [0.05, 0.05, 0.05]
occupation_matrix = fel.occupation_matrix(OW, skip=0, segments=1000)
maxima_matrix = fel.find_maxima(occupation_matrix, box=box_voxels, edge_length=0.05)
maxima_matrix = fel.add_distances(maxima_matrix, "cylindrical", box / 2)
r_bins = np.arange(0, 2, 0.02)
distance_bins = np.arange(0.05, 2.05, 0.1)
energy_df = fel.distance_resolved_energies(
maxima_matrix, distance_bins, r_bins, box, 225
)
result = fel.find_energy_maxima(energy_df, r_min=0.05, r_max=0.15)
assert (np.round(np.array(result["energy"])) == np.round(test_array)).all()

View File

@ -31,16 +31,3 @@ def test_filon_fourier_transformation(logdata):
xdata, xdata, frequencies=freqs, derivative='linear', imag=False xdata, xdata, frequencies=freqs, derivative='linear', imag=False
) )
assert np.isclose(filon_imag.real, filon_real).all() assert np.isclose(filon_imag.real, filon_real).all()
def test_histogram():
data = np.random.rand(100)
bins = np.linspace(0, 1)
np_hist = np.histogram(data, bins=bins)[0]
ut_hist = utils.histogram(data, bins=bins)[0]
assert (np_hist == ut_hist).all()
bins = np.linspace(0.3, 1.5)
np_hist = np.histogram(data, bins=bins)[0]
ut_hist = utils.histogram(data, bins=bins)[0]
assert (np_hist == ut_hist).all()