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 mdevaluate
from mdevaluate import free_energy_landscape as fel
import mdevaluate.extra.free_energy_landscape as fel
@pytest.fixture
@ -15,40 +15,40 @@ def trajectory(request):
def test_get_fel(trajectory):
test_array = np.array(
[
0.0,
12.87438176,
4.95868203,
11.02055197,
5.44195534,
6.73933442,
3.30971789,
6.10424055,
8.56153733,
5.45777331,
5.64545817,
8.42100423,
6.28132121,
7.4777172,
11.64839354,
4.52566354,
40.84730838,
93.86241602,
140.3039937,
173.55970021,
174.46253634,
174.60905476,
178.57658092,
182.43001192,
180.57916378,
176.49886217,
178.96018547,
181.13561782,
178.31026314,
176.08903996,
180.71215345,
181.59703135,
180.34329368,
187.02474488,
197.99167477,
214.05788031,
245.58571282,
287.52457507,
331.53492965,
]
)
oxygens_water = trajectory.subset(atom_name="OW", residue_name="SOL")
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,
)
OW = trajectory.subset(atom_name="OW")
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
)
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()