Skip to content

Commit

Permalink
fix dtype json cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
sroet committed Aug 14, 2024
1 parent a5fdb71 commit 4d4a283
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pytom_tm/tmjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def load_json_to_tmjob(
with open(file_name, "r") as fstream:
data = json.load(fstream)

# wrangle dtypes
output_dtype = data.get("output_dtype", "float32")
output_dtype = np.dtype(output_dtype)

job = TMJob(
data["job_key"],
data["log_level"],
Expand Down Expand Up @@ -74,7 +78,7 @@ def load_json_to_tmjob(
particle_diameter=data.get("particle_diameter", None),
random_phase_correction=data.get("random_phase_correction", False),
rng_seed=data.get("rng_seed", 321),
output_dtype=data.get("output_dtype", np.float32),
output_dtype=output_dtype,
)
# if the file originates from an old version set the phase shift for compatibility
if (
Expand Down Expand Up @@ -527,6 +531,8 @@ def write_to_json(self, file_name: pathlib.Path) -> None:
for key, value in d.items():
if isinstance(value, pathlib.Path):
d[key] = str(value)
if isinstance(value, np.dtype):
d[key] = str(value)
with open(file_name, "w") as fstream:
json.dump(d, fstream, indent=4)

Expand Down

0 comments on commit 4d4a283

Please sign in to comment.