Skip to content

Commit

Permalink
Accept 1 and 0 when reading boolean. SetupDt (model.setup) contain on…
Browse files Browse the repository at this point in the history
…ly integer 0 and 1 but not Python boolean, thus Smash cannot read its own setup. This slight modification fix this pb. it is now possible to extract setup from a model without write it in hdf5 and create a new model from this identical setup (just warning are displayed because unrecognize options).
  • Loading branch information
maximejay committed Jun 24, 2024
1 parent a9dda3c commit c4f2bbe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion smash/core/model/_standardize.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@


def _standardize_model_setup_bool(key: str, value: bool) -> bool:
if not isinstance(value, bool):
if not (isinstance(value, bool) or isinstance(value, int)):
raise TypeError(f"{key} model setup must be a boolean")
elif isinstance(value, int):
if value == 0:
value = False
elif value == 1:
value = True
else:
raise TypeError(f"{key} model setup must be a boolean or integer (0,1)")

return value

Expand Down

0 comments on commit c4f2bbe

Please sign in to comment.