Skip to content
Snippets Groups Projects
Commit d270bc59 authored by Andi Gerken's avatar Andi Gerken
Browse files

Convert Moritz: don't try to save if not valid.

parent e6373764
Branches
No related tags found
No related merge requests found
...@@ -35,7 +35,8 @@ for f in tqdm(files): ...@@ -35,7 +35,8 @@ for f in tqdm(files):
# print("Handling file %s" % f.relative_to(input)) # print("Handling file %s" % f.relative_to(input))
old = h5py.File(f) old = h5py.File(f)
new = robofish.io.File(world_size=old.attrs["world"]) world = old.attrs["world"] if "world" in old.attrs else [100, 100]
new = robofish.io.File(world_size=world)
new.attrs.update( new.attrs.update(
{a: old.attrs[a] for a in old.attrs.keys() if a not in ["world", "time_step"]} {a: old.attrs[a] for a in old.attrs.keys() if a not in ["world", "time_step"]}
...@@ -48,6 +49,11 @@ for f in tqdm(files): ...@@ -48,6 +49,11 @@ for f in tqdm(files):
poses=e_data, poses=e_data,
monotonic_step=old.attrs["time_step"], monotonic_step=old.attrs["time_step"],
) )
if not new.validate(strict_validate=False)[0]:
print(
f"File {input.relative_to(input)} could not be converted to a valid file. The error was:\n {new.validate(strict_validate=False)[1]}."
)
continue
new.save(output / f.relative_to(input)) new.save(output / f.relative_to(input))
# print("Saved converted file") # print("Saved converted file")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment