Skip to content

Commit

Permalink
Merge branch 'fix/parameter_overwriting' into 'main'
Browse files Browse the repository at this point in the history
fix overwriting of already registered parameters

See merge request es/ai/hannah/hannah!408
  • Loading branch information
moreib committed Oct 2, 2024
2 parents d29695c + 37ac378 commit b88cc74
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions hannah/nas/parameters/parametrize.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ def init_fn(self, *args, **kwargs):
for p in params:
n = name + f"_{idx}"
self._PARAMETERS[n] = p
elif isinstance(arg, Sequence):
elif isinstance(arg, Sequence): # FIXME: Strings are registered as sequence
for idx, param in enumerate(arg):
if is_parametrized(param):
if isinstance(param, Parameter):
if not param.is_registered():
param.register()
n = f"{name}_{idx}"
self._PARAMETERS[n] = param
n = f"{name}_{idx}"
self._PARAMETERS[n] = param
if isinstance(param, Expression):
params = extract_parameter_from_expression(param)
for idx2, p in enumerate(params):
if not p.is_registered():
p.register()
n = f"{name}_{idx}_{idx2}"
self._PARAMETERS[n] = p
n = f"{name}_{idx}_{idx2}"
self._PARAMETERS[n] = p

for name, arg in kwargs.items():
if isinstance(arg, (list, tuple)):
Expand Down

0 comments on commit b88cc74

Please sign in to comment.