Skip to content

Commit

Permalink
manage setattr() for dictionaries
Browse files Browse the repository at this point in the history
  • Loading branch information
patquem committed Feb 12, 2024
1 parent 59948f2 commit 18e7ae1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fitspy/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,14 @@ def set_attributes(self, model_dict):
if 'xtol' in keys:
self.fit_params['xtol'] = model_dict.pop('xtol')

for key in vars(self).keys():
if key in keys:
setattr(self, key, model_dict[key])
for key, val in vars(self).items():
if isinstance(val, dict):
for key2 in val.keys():
if key2 in model_dict[key].keys():
val[key2] = model_dict[key][key2]
else:
if key in keys:
setattr(self, key, model_dict[key])

if 'peak_models' in keys:
self.peak_index = itertools.count(start=1)
Expand Down

0 comments on commit 18e7ae1

Please sign in to comment.