Skip to content

Commit 933d40d

Browse files
authored
Merge pull request #180 from molssi-seamm/dev
Bugfix: Incorrect handling of JSON properties
2 parents 6379f2f + 23d3089 commit 933d40d

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
=======
22
History
33
=======
4+
2024.12.7 -- Bugfix: Incorrect handling of JSON properties
5+
* Any properties that were not a scalar had an issue when being transformed to and
6+
from JSON. This is now fixed.
7+
* Truncated values with known units reasonablt so that they are more readable in
8+
tables. For example, 1.23400000001 kJ/mol is now 1.234 kJ/mol.
9+
410
2024.11.29 -- Chemical formulas option for system names, cleaner tables.
511
* Added chemical formula to possible names for systems and configurations.
612
* Truncated results put in tables, based on units, to make more readable.

seamm/node.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,24 +1106,11 @@ def store_results(
11061106
else:
11071107
factor = Q_(1, current_units).m_as(units)
11081108
tmp = scale(data[key], factor)
1109-
properties.put(
1110-
_property, json.dumps(tmp, separators=(",", ":"))
1111-
)
1109+
properties.put(_property, tmp)
11121110
else:
1113-
if result_metadata["dimensionality"] == "scalar":
1114-
properties.put(_property, data[key])
1115-
else:
1116-
properties.put(
1117-
_property,
1118-
json.dumps(data[key], separators=(",", ":")),
1119-
)
1120-
else:
1121-
if result_metadata["dimensionality"] == "scalar":
11221111
properties.put(_property, data[key])
1123-
else:
1124-
properties.put(
1125-
_property, json.dumps(data[key], separators=(",", ":"))
1126-
)
1112+
else:
1113+
properties.put(_property, data[key])
11271114

11281115
# Store as JSON
11291116
if "json" in value:
@@ -1299,9 +1286,12 @@ def store_results(
12991286
)
13001287
else:
13011288
if result_metadata["dimensionality"] == "scalar":
1302-
table.at[row_index, column] = round(
1303-
data[key], def_fmt[units]
1304-
)
1289+
if units in def_fmt:
1290+
table.at[row_index, column] = round(
1291+
data[key], def_fmt[units]
1292+
)
1293+
else:
1294+
table.at[row_index, column] = data[key]
13051295
else:
13061296
table.at[row_index, column] = json.dumps(
13071297
data[key], separators=(",", ":")

0 commit comments

Comments
 (0)