Skip to content

Commit 6c984e6

Browse files
committed
update regression test baselines
1 parent 44bd758 commit 6c984e6

8 files changed

Lines changed: 84 additions & 72 deletions

File tree

‎CodeEntropy/entropy/nodes/configurational.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def _compute_ua_entropy_for_group(
156156

157157
for res_id, res in enumerate(residues):
158158
states = states_ua.get((group_id, res_id))
159-
val = self._entropy_or_zero(ce, states, n_frames)
159+
val = self._entropy_or_zero(ce, states)
160160
total += val
161161

162162
if reporter is not None:
@@ -184,18 +184,17 @@ def _compute_residue_entropy_for_group(
184184
) -> float:
185185
"""Compute residue-level entropy for a group."""
186186
group_states = self._get_group_states(states_res, group_id)
187-
return self._entropy_or_zero(ce, group_states, n_frames)
187+
return self._entropy_or_zero(ce, group_states)
188188

189189
def _entropy_or_zero(
190190
self,
191191
ce: ConformationalEntropy,
192192
states: StateSequence | None,
193-
n_frames: int,
194193
) -> float:
195194
"""Return entropy value or zero if no state data exists."""
196195
if not self._has_state_data(states):
197196
return 0.0
198-
return float(ce.conformational_entropy_calculation(states, n_frames))
197+
return float(ce.conformational_entropy_calculation(states))
199198

200199
@staticmethod
201200
def _get_group_states(

‎CodeEntropy/entropy/orientational.py‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Orientational entropy calculations.
22
33
This module defines `OrientationalEntropy`, which computes orientational entropy
4-
from a neighbour count and symmetry information.
4+
from a neighbor count and symmetry information.
55
"""
66

77
from __future__ import annotations
@@ -54,11 +54,11 @@ def __init__(
5454

5555
def calculate(
5656
self,
57-
neighbour_count: float,
57+
neighbor_count: float,
5858
symmetry_number: int,
5959
linear: bool,
6060
) -> OrientationalEntropyResult:
61-
"""Calculate orientational entropy from neighbour counts.
61+
"""Calculate orientational entropy from neighbor counts.
6262
6363
The number of orientations is estimated as:
6464
Ω = sqrt(N_av^3 * π)/symmetry_number for non-linear molecules
@@ -68,34 +68,34 @@ def calculate(
6868
6969
S = R * ln(Ω)
7070
71-
where N_av is the average number of neighbours and R is the gas constant.
71+
where N_av is the average number of neighbors and R is the gas constant.
7272
7373
Args:
74-
neighbours: average number of neighbours
74+
neighbors: average number of neighbors
7575
symmetry_number: symmetry number of molecule of interest
7676
linear: True if molecule of interest is linear
7777
7878
Returns:
7979
OrientationalEntropyResult containing the total entropy in J/mol/K.
8080
8181
Raises:
82-
ValueError if number of neighbours is negative.
82+
ValueError if number of neighbors is negative.
8383
"""
84-
if neighbour_count < 0:
85-
raise ValueError(f"neighbour_count must be >= 0, got {neighbour_count}")
84+
if neighbor_count < 0:
85+
raise ValueError(f"neighbor_count must be >= 0, got {neighbor_count}")
8686

87-
omega = self._omega(neighbour_count, symmetry_number, linear)
87+
omega = self._omega(neighbor_count, symmetry_number, linear)
8888

8989
total = self._gas_constant * math.log(omega)
9090
logger.debug(f"Orientational entropy total: {total}")
9191

9292
return total
9393

94-
def _omega(neighbour_count: int, symmetry: int, linear: bool) -> float:
94+
def _omega(self, neighbor_count: int, symmetry: int, linear: bool) -> float:
9595
"""Compute the number of orientations Ω.
9696
9797
Args:
98-
neighbour_count: average number of neighbours.
98+
neighbor_count: average number of neighbors.
9999
symmetry_number: The symmetry number of the molecule.
100100
linear: Is the molecule linear (True or False).
101101
@@ -107,12 +107,11 @@ def _omega(neighbour_count: int, symmetry: int, linear: bool) -> float:
107107
omega = 1
108108
else:
109109
if linear:
110-
omega = neighbour_count / symmetry
110+
omega = neighbor_count / symmetry
111111
else:
112-
omega = np.sqrt((neighbour_count**3) * math.pi) / symmetry
112+
omega = np.sqrt((neighbor_count**3) * math.pi) / symmetry
113113

114114
# avoid negative orientational entropy
115-
if omega < 1:
116-
omega = 1
115+
omega = max(omega, 1)
117116

118117
return omega

‎CodeEntropy/levels/axes.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_residue_axes(self, data_container, index: int, residue=None):
6767
The translational and rotational axes at the residue level.
6868
6969
- Identify the residue (either provided or selected by `resindex index`).
70-
- Determine whether the residue is bonded to neighbouring residues
70+
- Determine whether the residue is bonded to neighboring residues
7171
(previous/next in sequence) using MDAnalysis bonded selections.
7272
- If there are *no* bonds to other residues:
7373
* Use a custom principal axes, from a moment-of-inertia (MOI) tensor

‎CodeEntropy/levels/neighbors.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Neighbours info for orientational entropy.
22
3-
This module finds the average number of neighbours, symmetry numbers, and
3+
This module finds the average number of neighbors, symmetry numbers, and
44
and linearity for each group.
55
These are used downstream to compute the orientational entropy.
66
"""
@@ -30,14 +30,15 @@ def __init__(self):
3030
self._universe = None
3131
self._groups = None
3232
self._levels = None
33+
self._search = Search()
3334

3435
def get_neighbors(self, universe, levels, groups, search_type):
3536
"""
3637
Find the neighbors relative to the central molecule.
3738
3839
The search defaults to using RAD, but an MDAnalysis method based
3940
on grid searches is also available.
40-
The average number of neighbours is calculated.
41+
The average number of neighbors is calculated.
4142
4243
Args:
4344
universe: MDAnalysis universe object for the system
@@ -67,12 +68,16 @@ def get_neighbors(self, universe, levels, groups, search_type):
6768

6869
if search_type == "RAD":
6970
# Use the relative angular distance method to find neighbors
70-
neighbors = Search.get_RAD_neighbors(universe, mol_id)
71+
neighbors = self._search.get_RAD_neighbors(
72+
universe=universe, mol_id=mol_id
73+
)
7174

7275
elif search_type == "grid":
7376
# Use MDAnalysis neighbor search.
74-
neighbors = Search.get_grid_neighbors(
75-
universe, mol_id, highest_level
77+
neighbors = self._search.get_grid_neighbors(
78+
universe=universe,
79+
mol_id=mol_id,
80+
highest_level=highest_level,
7681
)
7782
else:
7883
# Raise error for unavailale search_type

‎CodeEntropy/levels/search.py‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
"""These functions find neighbours.
1+
"""These functions find neighbors.
22
3-
There are different functions for different types of neighbour searching.
3+
There are different functions for different types of neighbor searching.
44
Currently RAD is the default with grid as an alternative.
55
"""
66

@@ -10,7 +10,7 @@
1010

1111
class Search:
1212
"""
13-
Class for functions to find neighbours.
13+
Class for functions to find neighbors.
1414
"""
1515

1616
def __init__(self):
@@ -20,6 +20,7 @@ def __init__(self):
2020
"""
2121

2222
self._universe = None
23+
self._mol_id = None
2324

2425
def get_RAD_neighbors(self, universe, mol_id):
2526
"""
@@ -51,29 +52,29 @@ def get_RAD_neighbors(self, universe, mol_id):
5152

5253
# Get indices of neighbors
5354
neighbor_indices = self._get_RAD_indices(
54-
central_position, sorted_dist, universe
55+
central_position, sorted_dist, universe, number_molecules
5556
)
5657

5758
return neighbor_indices
5859

59-
def _get_RAD_indices(self, i_coords, sorted_distances, system):
60+
def _get_RAD_indices(self, i_coords, sorted_distances, system, number_molecules):
6061
# pylint: disable=too-many-locals
6162
r"""
6263
For a given set of atom coordinates, find its RAD shell from the distance
6364
sorted list, truncated to the closest 30 molecules.
6465
6566
This function calculates coordination shells using RAD the relative
6667
angular distance, as defined first in DOI:10.1063/1.4961439
67-
where molecules are defined as neighbours if
68+
where molecules are defined as neighbors if
6869
they fulfil the following condition:
6970
7071
.. math::
7172
\Bigg(\frac{1}{r_{ij}}\Bigg)^2 >
7273
\Bigg(\frac{1}{r_{ik}}\Bigg)^2 \cos \theta_{jik}
7374
74-
For a given particle :math:`i`, neighbour :math:`j` is in its coordination
75+
For a given particle :math:`i`, neighbor :math:`j` is in its coordination
7576
shell if :math:`k` is not blocking particle :math:`j`. In this implementation
76-
of RAD, we enforce symmetry, whereby neighbouring particles must be in each
77+
of RAD, we enforce symmetry, whereby neighboring particles must be in each
7778
others coordination shells.
7879
7980
Args:
@@ -84,17 +85,18 @@ def _get_RAD_indices(self, i_coords, sorted_distances, system):
8485
Returns:
8586
shell: list of indices of particles in the RAD shell of neighbors.
8687
"""
87-
# 1. truncate neighbour list to closest 30 united atoms
88+
# 1. truncate neighbor list to closest 30 united atoms and iterate
89+
# through neighbors from closest to furthest/
8890
shell = []
8991
count = -1
90-
# 2. iterate through neighbours from closest to furthest
91-
for y in range(30):
92+
limit = min(number_molecules - 1, 30)
93+
for y in range(limit):
9294
count += 1
9395
j_idx = sorted_distances[y][0]
9496
j_coords = system.atoms.fragments[j_idx].center_of_mass()
9597
r_ij = sorted_distances[y][1]
9698
blocked = False
97-
# 3. iterate through neighbours other than atom j and check if they block
99+
# 3. iterate through neighbors other than atom j and check if they block
98100
# it from molecule i
99101
for z in range(count): # only closer units can block
100102
k_idx = sorted_distances[z][0]
Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"args": {
33
"top_traj_file": [
4-
"/home/tdo96567/BioSim/CodeEntropy/tests/data/dna/md_A4_dna.tpr",
5-
"/home/tdo96567/BioSim/CodeEntropy/tests/data/dna/md_A4_dna_xf.trr"
4+
"/home/ogo12949/CodeEntropy/.testdata/dna/md_A4_dna.tpr",
5+
"/home/ogo12949/CodeEntropy/.testdata/dna/md_A4_dna_xf.trr"
66
],
77
"force_file": null,
88
"file_format": null,
@@ -14,18 +14,19 @@
1414
"bin_width": 30,
1515
"temperature": 298.0,
1616
"verbose": false,
17-
"output_file": "/tmp/pytest-of-tdo96567/pytest-60/test_regression_matches_baseli3/job001/output_file.json",
17+
"output_file": "/tmp/pytest-of-ogo12949/pytest-5/test_regression_matches_baseli0/job001/output_file.json",
1818
"force_partitioning": 0.5,
1919
"water_entropy": true,
2020
"grouping": "molecules",
2121
"combined_forcetorque": true,
22-
"customised_axes": true
22+
"customised_axes": true,
23+
"search_type": "RAD"
2324
},
2425
"provenance": {
25-
"python": "3.14.0",
26-
"platform": "Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.39",
27-
"codeentropy_version": "1.0.7",
28-
"git_sha": "226b37f7b206adba1b60253c41c7a0d467e75a58"
26+
"python": "3.13.5",
27+
"platform": "Linux-6.17.0-1011-oem-x86_64-with-glibc2.39",
28+
"codeentropy_version": "2.0.0",
29+
"git_sha": "44bd758498dfdd07eb391ee86e6ff2d86ea2bcb8"
2930
},
3031
"groups": {
3132
"0": {
@@ -36,10 +37,11 @@
3637
"residue:Rovibrational": 3.376800684085249,
3738
"polymer:FTmat-Transvibrational": 12.341104347192612,
3839
"polymer:FTmat-Rovibrational": 0.0,
39-
"united_atom:Conformational": 7.269386795471401,
40-
"residue:Conformational": 0.0
40+
"united_atom:Conformational": 7.0411434528236345,
41+
"residue:Conformational": 0.0,
42+
"polymer:Orientational": 4.758905336627712
4143
},
42-
"total": 22.989452505761392
44+
"total": 27.52011449974134
4345
},
4446
"1": {
4547
"components": {
@@ -50,9 +52,10 @@
5052
"polymer:FTmat-Transvibrational": 11.11037253388596,
5153
"polymer:FTmat-Rovibrational": 0.0,
5254
"united_atom:Conformational": 6.410455987098191,
53-
"residue:Conformational": 0.46183561256411515
55+
"residue:Conformational": 0.46183561256411515,
56+
"polymer:Orientational": 4.758905336627712
5457
},
55-
"total": 20.387448519462218
58+
"total": 25.14635385608993
5659
}
5760
}
5861
}
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"args": {
33
"top_traj_file": [
4-
"/home/tdo96567/BioSim/CodeEntropy/tests/data/methane/molecules.top",
5-
"/home/tdo96567/BioSim/CodeEntropy/tests/data/methane/trajectory.crd"
4+
"/home/ogo12949/CodeEntropy/.testdata/methane/molecules.top",
5+
"/home/ogo12949/CodeEntropy/.testdata/methane/trajectory.crd"
66
],
7-
"force_file": "/home/tdo96567/BioSim/CodeEntropy/tests/data/methane/forces.frc",
7+
"force_file": "/home/ogo12949/CodeEntropy/.testdata/methane/forces.frc",
88
"file_format": "MDCRD",
99
"kcal_force_units": false,
1010
"selection_string": "all",
@@ -14,27 +14,29 @@
1414
"bin_width": 30,
1515
"temperature": 112.0,
1616
"verbose": false,
17-
"output_file": "/tmp/pytest-of-tdo96567/pytest-60/test_regression_matches_baseli5/job001/output_file.json",
17+
"output_file": "/tmp/pytest-of-ogo12949/pytest-5/test_regression_matches_baseli1/job001/output_file.json",
1818
"force_partitioning": 0.5,
1919
"water_entropy": true,
2020
"grouping": "molecules",
2121
"combined_forcetorque": true,
22-
"customised_axes": true
22+
"customised_axes": true,
23+
"search_type": "RAD"
2324
},
2425
"provenance": {
25-
"python": "3.14.0",
26-
"platform": "Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.39",
27-
"codeentropy_version": "1.0.7",
28-
"git_sha": "226b37f7b206adba1b60253c41c7a0d467e75a58"
26+
"python": "3.13.5",
27+
"platform": "Linux-6.17.0-1011-oem-x86_64-with-glibc2.39",
28+
"codeentropy_version": "2.0.0",
29+
"git_sha": "44bd758498dfdd07eb391ee86e6ff2d86ea2bcb8"
2930
},
3031
"groups": {
3132
"0": {
3233
"components": {
3334
"united_atom:Transvibrational": 75.73291215434239,
3435
"united_atom:Rovibrational": 68.80103728327107,
35-
"united_atom:Conformational": 0.0
36+
"united_atom:Conformational": 0.0,
37+
"united_atom:Orientational": 5.499485304173264
3638
},
37-
"total": 144.53394943761344
39+
"total": 150.03343474178672
3840
}
3941
}
4042
}

0 commit comments

Comments
 (0)