Skip to content

Commit

Permalink
FIX: fix code check with some bugs detected by ruff 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
nghi-truyen committed Jun 28, 2024
1 parent f47b00e commit 6f30a7a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions smash/core/simulation/_standardize.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def _standardize_simulation_optimize_options_bounds(
f"Choices: {parameters}"
)
else:
TypeError("bounds optimize_options must be a dictionary")
raise TypeError("bounds optimize_options must be a dictionary")

parameters_bounds = dict(
**model.get_rr_parameters_bounds(),
Expand Down Expand Up @@ -269,7 +269,7 @@ def _standardize_simulation_optimize_options_control_tfm(
f"Choices: {F90_OPTIMIZER_CONTROL_TFM[optimizer]}"
)
else:
TypeError("control_tfm optimize_options must be a str")
raise TypeError("control_tfm optimize_options must be a str")

return control_tfm

Expand Down
3 changes: 1 addition & 2 deletions smash/io/handler/_hdf5_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ def _load_hdf5_to_dict(h5: h5py.File | h5py.Group) -> dict[str, Any]:
elif isinstance(value, h5py.Dataset):
dct[key] = _load_hdf5_dataset_to_npndarray(value)

for key, value in h5.attrs.items():
dct[key] = value
dct.update(dict(h5.attrs.items()))

return dct

Expand Down
4 changes: 2 additions & 2 deletions smash/tests/core/simulation/test_bayesian_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def generic_custom_bayesian_optimize(model: smash.Model, **kwargs) -> dict:
},
]

for i, kwargs in enumerate(custom_sets):
instance = smash.bayesian_optimize(model, **kwargs)
for i, inner_kwargs in enumerate(custom_sets):
instance = smash.bayesian_optimize(model, **inner_kwargs)

qsim = instance.response.q[:].flatten()
qsim = qsim[::10] # extract values at every 10th position
Expand Down
4 changes: 2 additions & 2 deletions smash/tests/core/simulation/test_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def generic_custom_optimize(model: smash.Model, **kwargs) -> dict:
},
]

for i, kwargs in enumerate(custom_sets):
instance = smash.optimize(model, **kwargs)
for i, inner_kwargs in enumerate(custom_sets):
instance = smash.optimize(model, **inner_kwargs)

qsim = instance.response.q[:].flatten()
qsim = qsim[::10] # extract values at every 10th position
Expand Down

0 comments on commit 6f30a7a

Please sign in to comment.