From b73acf1c52e86738c5afbd0f99598b85a30f190d Mon Sep 17 00:00:00 2001 From: Jintao Date: Tue, 20 Aug 2024 10:54:16 +0800 Subject: [PATCH] Modify `compare_confs` for different cases If we don't need the conversion, meaning `dmat1` and `dmat2` are both given, we can start the subsequent steps directly. --- arc/species/converter.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arc/species/converter.py b/arc/species/converter.py index bd35a1a07d..32fb74ead2 100644 --- a/arc/species/converter.py +++ b/arc/species/converter.py @@ -2053,6 +2053,9 @@ def compare_confs(xyz1: dict, rtol: float = 0.01, atol: float = 0.1, rmsd_score: bool = False, + skip_conversion: bool = False, + dmat1: Optional[np.ndarray] = None, + dmat2: Optional[np.ndarray] = None, ) -> Union[float, bool]: """ Compare two Cartesian coordinates representing conformers using distance matrices. @@ -2066,6 +2069,9 @@ def compare_confs(xyz1: dict, rtol (float): The relative tolerance parameter (see Notes). atol (float): The absolute tolerance parameter (see Notes). rmsd_score (bool): Whether to output a root-mean-square deviation score of the two distance matrices. + skip_conversion (bool): Whether to skip converting xyz to distance matrices. + dmat1 (np.ndarray, optional): The distance matrix of conformer 1. + dmat2 (np.ndarray, optional): The distance matrix of conformer 2. Returns: Union[float, bool]: @@ -2073,8 +2079,9 @@ def compare_confs(xyz1: dict, ``True`` if they do. - If ``rmsd_score`` is ``True``: The RMSD score of two distance matrices. """ - xyz1, xyz2 = check_xyz_dict(xyz1), check_xyz_dict(xyz2) - dmat1, dmat2 = xyz_to_dmat(xyz1), xyz_to_dmat(xyz2) + if not skip_conversion: + xyz1, xyz2 = check_xyz_dict(xyz1), check_xyz_dict(xyz2) + dmat1, dmat2 = xyz_to_dmat(xyz1), xyz_to_dmat(xyz2) if rmsd_score: # Distance matrix is symmetric, only need the upper triangular part to compute rmsd. rmsd = calc_rmsd(np.triu(dmat1), np.triu(dmat2))