Skip to content

Commit 191885f

Browse files
authored
Merge pull request #185 from molssi-seamm/dev
Enhancement when storing results in tables.
2 parents e34c3d1 + e34e0a9 commit 191885f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

HISTORY.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
=======
22
History
33
=======
4+
2025.5.27 -- Enhancement when storing results in tables.
5+
* When storing e.g. diffusivity results in a table, the diffusion constants are
6+
keyed by the SMILES of the component. If it is a pure fluid with only one
7+
component, this enhancement allows using a column name with the SMILES key, which
8+
is useful if running a number of different fluids. Otherwise each has unique
9+
columns including the SMILES in the column name.
10+
411
2025.4.30 -- Bugfix: Error naming systems and configurations
512
* Fixed a bug that occurred trying to set the name of a system or configuration to
613
early, when it had atoms, causing errors.

seamm/node.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,11 +1169,18 @@ def store_results(
11691169
table = table_handle["table"]
11701170

11711171
# create the column as needed handling "key"ed columns
1172-
if "{key}" in column:
1172+
# Special case: if there is only one key, the value can be put
1173+
# in the column without a keyed name.
1174+
if "{key}" in column or isinstance(data[key], dict):
11731175
if not isinstance(data[key], dict):
11741176
raise ValueError(
11751177
f"Data for a keyed column '{column}' is not a dictionary. "
1176-
f"{type(data[key])}"
1178+
f"{type(data[key]).__name__}"
1179+
)
1180+
if "{key}" not in column and len(data[key]) > 1:
1181+
raise ValueError(
1182+
f"Data for column '{column}' has more than one key. "
1183+
"The column name should contain a key."
11771184
)
11781185
for ckey, value in data[key].items():
11791186
keyed_column = column.replace("{key}", ckey)

0 commit comments

Comments
 (0)