Skip to content

Commit fb89188

Browse files
authored
Merge pull request #239 from boutproject/fix-is_restart-reloading-old-data
Add "is_restart" to metadata when reloading old data
2 parents 7db6609 + 0768edb commit fb89188

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

xbout/load.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ def attrs_remove_section(obj, section):
203203

204204
# Restore metadata from attrs
205205
metadata = attrs_to_dict(ds, "metadata")
206+
if "is_restart" not in metadata:
207+
# Loading data that was saved with a version of xbout from before
208+
# "is_restart" was added, so need to add it to the metadata.
209+
metadata["is_restart"] = int(is_restart)
206210
ds.attrs["metadata"] = metadata
207211
# Must do this for all variables and coordinates in dataset too
208212
for da in chain(ds.data_vars.values(), ds.coords.values()):

0 commit comments

Comments
 (0)