From daba5117aaa825cab3d69739a1e45c4ed6ba72d9 Mon Sep 17 00:00:00 2001 From: Gilberto Nardi <58424819+gilbogilb@users.noreply.github.com> Date: Mon, 2 Feb 2026 11:54:35 +0100 Subject: [PATCH 1/3] Update import path for nearest_neighbours function --- snow/descriptors/lae.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snow/descriptors/lae.py b/snow/descriptors/lae.py index 90a5196..b77e4d8 100644 --- a/snow/descriptors/lae.py +++ b/snow/descriptors/lae.py @@ -1,6 +1,6 @@ import numpy as np import os -from snow.lodispp.utils import nearest_neighbours +from snow.descriptors.utils import nearest_neighbours from snow.descriptors.coordination import agcn_calculator From 37276ac784642e51cc1f19c40832b90781d3cbb9 Mon Sep 17 00:00:00 2001 From: Gilberto Nardi <58424819+gilbogilb@users.noreply.github.com> Date: Mon, 2 Feb 2026 12:09:03 +0100 Subject: [PATCH 2/3] Rename functions related to gyration and inertia tensors long names made shorter --- snow/descriptors/shape_descriptors.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/snow/descriptors/shape_descriptors.py b/snow/descriptors/shape_descriptors.py index 5c951da..4db2199 100644 --- a/snow/descriptors/shape_descriptors.py +++ b/snow/descriptors/shape_descriptors.py @@ -46,7 +46,7 @@ def geometric_com(index_frame: int, coords: np.ndarray): gcom = np.mean(coords, axis=0) return gcom -def compute_gyration_tensor(positions, masses=None, COM=True): +def gyr_tensor(positions, masses=None, COM=True): """ Computes the gyration tensor for a given set of coordinates. \n This can be done in the center of mass reference system or in the raw provided coordinates. @@ -86,7 +86,7 @@ def compute_gyration_tensor(positions, masses=None, COM=True): return np.array([[Sxx, Sxy, Sxz], [Sxy, Syy, Syz], [Sxz, Syz, Szz]]) -def compute_gyration_desc_from_tensor(gyration_tensor): +def gyr_desc_from_tensor(gyration_tensor): """ Computes general shape descriptors (gyration radius, asphericity, acylindricity, relative shape anisotropy) from the gyration tensor @@ -122,7 +122,7 @@ def compute_gyration_desc_from_tensor(gyration_tensor): return rg, b, c, k -def compute_gyration_descriptors(positions, masses=None, COM=True): +def gyr_desc(positions, masses=None, COM=True): """ Computes general shape descriptors obtained from the gyration tensor \n (gyration radius, asphericity, acylindricity, relative shape anisotropy) directly from the provided atomic positions. \n @@ -150,11 +150,11 @@ def compute_gyration_descriptors(positions, masses=None, COM=True): relative shape anisotropy """ - return compute_gyration_desc_from_tensor(compute_gyration_tensor(positions, masses, COM)) + return gyr_desc_from_tensor(gyr_tensor(positions, masses, COM)) -def compute_inertia_tensor(positions, masses=None, COM=True): +def inertia_tensor(positions, masses=None, COM=True): """ Computes the inertia tensor for a given set of coordinates. \n @@ -194,7 +194,7 @@ def compute_inertia_tensor(positions, masses=None, COM=True): return np.array([[Ixx, Ixy, Ixz], [Ixy, Iyy, Iyz], [Ixz, Iyz, Izz]]) -def compute_aspect_ratio_from_tensor(inertia_tensor): +def aspect_ratio_from_tensor(inertia_tensor): """ Computes the aspect ratio, a shape descriptor obtained from the inertia tensor. @@ -211,7 +211,7 @@ def compute_aspect_ratio_from_tensor(inertia_tensor): -def compute_aspect_ratio(positions, masses=None, COM=True): +def aspect_ratio(positions, masses=None, COM=True): """ Computes the aspect ratio, a shape descriptor derived from the inertia tensor, for a given set of coordinates. \n This can be done in the center of mass reference system or in the raw provided coordinates @@ -232,9 +232,9 @@ def compute_aspect_ratio(positions, masses=None, COM=True): aspect ratio """ - return compute_aspect_ratio_from_tensor(compute_inertia_tensor(positions, masses, COM)) + return aspect_ratio_from_tensor(inertia_tensor(positions, masses, COM)) -def compute_gyr_rad(positions, masses=None): +def gyr_rad(positions, masses=None): """ Computes the gyration radius, which corresponds to the average weighted by the masses of\n atoms in the system. @@ -257,4 +257,4 @@ def compute_gyr_rad(positions, masses=None): centered = positions - np.average(positions, axis=0, weights=masses) - return np.sqrt( np.average( np.sum(centered**2, axis=1), weights=masses ) ) \ No newline at end of file + return np.sqrt( np.average( np.sum(centered**2, axis=1), weights=masses ) ) From ed5118d0cc309e7b24daaecbee5a2765354651b4 Mon Sep 17 00:00:00 2001 From: Gilberto Nardi <58424819+gilbogilb@users.noreply.github.com> Date: Mon, 2 Feb 2026 12:20:37 +0100 Subject: [PATCH 3/3] Add index_frame parameter to shape descriptor functions Updated gyr_desc, aspect_ratio, and gyr_rad functions to include index_frame parameter for trajectory reference. --- snow/descriptors/shape_descriptors.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/snow/descriptors/shape_descriptors.py b/snow/descriptors/shape_descriptors.py index 4db2199..e4c4277 100644 --- a/snow/descriptors/shape_descriptors.py +++ b/snow/descriptors/shape_descriptors.py @@ -122,7 +122,7 @@ def gyr_desc_from_tensor(gyration_tensor): return rg, b, c, k -def gyr_desc(positions, masses=None, COM=True): +def gyr_desc(index_frame: int, positions, masses=None, COM=True): """ Computes general shape descriptors obtained from the gyration tensor \n (gyration radius, asphericity, acylindricity, relative shape anisotropy) directly from the provided atomic positions. \n @@ -132,6 +132,8 @@ def gyr_desc(positions, masses=None, COM=True): Parameters ---------- + index_frame (int): + Index of the frame in the trajectory (for reference only - not used now). positions : ndarray (n,3) Array of the coordinates of the atoms forming the system. masses : ndarray @@ -211,13 +213,15 @@ def aspect_ratio_from_tensor(inertia_tensor): -def aspect_ratio(positions, masses=None, COM=True): +def aspect_ratio(index_frame: int, positions, masses=None, COM=True): """ Computes the aspect ratio, a shape descriptor derived from the inertia tensor, for a given set of coordinates. \n This can be done in the center of mass reference system or in the raw provided coordinates Parameters ---------- + index_frame (int): + Index of the frame in the trajectory (for reference only - not used now). positions : ndarray Nx3 Array of the coordinates of the atoms in the system. masses : ndarray @@ -234,13 +238,15 @@ def aspect_ratio(positions, masses=None, COM=True): return aspect_ratio_from_tensor(inertia_tensor(positions, masses, COM)) -def gyr_rad(positions, masses=None): +def gyr_rad(index_frame: int, positions, masses=None): """ Computes the gyration radius, which corresponds to the average weighted by the masses of\n atoms in the system. Parameters ---------- + index_frame (int): + Index of the frame in the trajectory (for reference only - not used now). positions : ndarray Nx3 Array of the coordinates of the atoms in the system. masses : ndarray