From b7d0b067fbbc6a953f11f29bf2d8f5f02e0ae262 Mon Sep 17 00:00:00 2001 From: Cade Duckworth <104414304+cadeduckworth@users.noreply.github.com> Date: Mon, 27 Mar 2023 12:22:59 -0500 Subject: [PATCH] Periodic Angle Padding (#242) * fix #241 * add .copy(deep=True) method for dataframe augmentation to avoid pandas potentially loosing changes to a df due to working on a copy after indexing * update CHANGES * note: Tests pass as before so no functional code changes but more robust code --- CHANGES | 2 ++ mdpow/workflows/dihedrals.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index dee0e09f..613ff8c5 100644 --- a/CHANGES +++ b/CHANGES @@ -30,6 +30,8 @@ Enhancements Fixes +* for mdpow.workflows.dihedrals.periodic_angle() implement .copy(deep=True) + to explicitly make a copy DataFrame of the data for angle padding (#242) * fix rcoulomb in CHARMM energy minimization MDP template file (PR #210) * fix ensemble.EnsembleAnalysis.check_groups_from_common_ensemble (#212) diff --git a/mdpow/workflows/dihedrals.py b/mdpow/workflows/dihedrals.py index a9ae5036..63b4d6a1 100644 --- a/mdpow/workflows/dihedrals.py +++ b/mdpow/workflows/dihedrals.py @@ -418,11 +418,11 @@ def periodic_angle(df, padding=45): ''' - df1 = df[df.dihedral > 180 - padding] + df1 = df[df.dihedral > 180 - padding].copy(deep=True) df1.dihedral -= 360 - df2 = df[df.dihedral < -180 + padding] + df2 = df[df.dihedral < -180 + padding].copy(deep=True) df2.dihedral += 360 - df_aug = pd.concat([df1, df, df2]).reset_index() + df_aug = pd.concat([df1, df, df2]).reset_index(drop=True) return df_aug