Skip to content

Commit 337de4a

Browse files
committed
Handle normalisation in a backwards compatible way.
1 parent c7ae572 commit 337de4a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/BioSimSpace/FreeEnergy/_relative.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,20 @@ def _somd2_extract(parquet_file, T=None, estimator="MBAR"):
10831083
# Convert to a pandas dataframe.
10841084
df = table.to_pandas()
10851085

1086+
# Normalise column names to :.5f string format so that comparisons are
1087+
# consistent regardless of whether the parquet was written with float keys
1088+
# (old sire) or formatted string keys (new sire).
1089+
df.columns = [
1090+
f"{float(c):.5f}"
1091+
if isinstance(c, (int, float))
1092+
or (
1093+
isinstance(c, str)
1094+
and c.replace(".", "", 1).replace("-", "", 1).isdigit()
1095+
)
1096+
else c
1097+
for c in df.columns
1098+
]
1099+
10861100
if is_mbar:
10871101
# Extract all columns other than those used for the gradient.
10881102
df = df[[x for x in df.columns if x not in lambda_grad]]

0 commit comments

Comments
 (0)