Skip to content

Instantly share code, notes, and snippets.

@thomasaarholt
Last active August 27, 2016 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasaarholt/9bda86c39b0a3a6517b0da5a35436cd8 to your computer and use it in GitHub Desktop.
Save thomasaarholt/9bda86c39b0a3a6517b0da5a35436cd8 to your computer and use it in GitHub Desktop.
Error thrown when trying to restore a model
>>> s = hs.load(...)
>>> m = s.create_model()
...
>>> m.store()
>>> s.models()
└── a
├── components
│ ├── C_K
│ ├── O_K
│ ├── Offset
│ ├── PowerLaw
│ ├── Zr_M2
│ ├── Zr_M3
│ ├── Zr_M4
│ └── Zr_M5
├── date = 2016-08-27 14:58:35
└── dimensions = (100|2047)
>>> m2 = s.models.restore("a")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-32-bbb5d66245c0> in <module>()
----> 1 m2 = cl.models.restore("a")
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/signal.py in restore(self, name)
227 name = self._check_name(name, True)
228 d = self._models.get_item(name + '._dict').as_dictionary()
--> 229 return self._signal.create_model(dictionary=copy.deepcopy(d))
230
231 def __repr__(self):
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/_signals/eels.py in create_model(self, ll, auto_background, auto_add_edges, GOS, dictionary)
1251 auto_add_edges=auto_add_edges,
1252 GOS=GOS,
-> 1253 dictionary=dictionary)
1254 return model
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/models/eelsmodel.py in __init__(self, signal1D, auto_background, auto_add_edges, ll, GOS, dictionary)
84 auto_background = False
85 auto_add_edges = False
---> 86 self._load_dictionary(dictionary)
87
88 if auto_background is True:
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/model.py in _load_dictionary(self, dic)
280
281 self.append(getattr(components, comp['_id_name'])(**init_args))
--> 282 id_dict.update(self[-1]._load_dictionary(comp))
283 # deal with twins:
284 for comp in dic['components']:
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/component.py in _load_dictionary(self, dic)
1179 if hasattr(self, idname):
1180 par = getattr(self, idname)
-> 1181 t_id = par._load_dictionary(p)
1182 id_dict[t_id] = par
1183 else:
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/component.py in _load_dictionary(self, dictionary)
183 """
184 if dictionary['_id_name'] == self._id_name:
--> 185 load_from_dictionary(self, dictionary)
186 return dictionary['self']
187 else:
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/misc/export_dictionary.py in load_from_dictionary(target, dic)
174 new_whitelist[key] = (flags_str, value)
175 else:
--> 176 attrsetter(target, key, value)
177 if len(flags_str):
178 new_whitelist[key] = (flags_str, None)
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/misc/utils.py in attrsetter(target, attrs, value)
66 if where != -1:
67 target = attrgetter(attrs[:where])(target)
---> 68 setattr(target, attrs[where + 1:], value)
69
70
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/component.py in _set_value(self, value)
214 raise ValueError(
215 "The length of the parameter must be ",
--> 216 self._number_of_elements)
217 else:
218 if not isinstance(value, tuple):
ValueError: ('The length of the parameter must be ', 40)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment