Skip to content

Commit

Permalink
Temporary fix for using the same pulse several times
Browse files Browse the repository at this point in the history
  • Loading branch information
M-superposition committed May 15, 2018
1 parent da8e20d commit a62d6dd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions qctoolkit/serialization.py
Expand Up @@ -471,6 +471,10 @@ def deserialize(self, representation: Union[str, Dict[str, Any]]) -> Serializabl
See also:
Serializable.deserialize
"""
if isinstance(representation, str):
if representation in self.__subpulses:
return self.__subpulses[representation].serializable

if isinstance(representation, str):
repr_ = json.loads(self.__storage_backend.get(representation))
repr_['identifier'] = representation
Expand All @@ -480,9 +484,16 @@ def deserialize(self, representation: Union[str, Dict[str, Any]]) -> Serializabl
module_name, class_name = repr_['type'].rsplit('.', 1)
module = __import__(module_name, fromlist=[class_name])
class_ = getattr(module, class_name)


repr_to_store = repr_.copy()
repr_.pop('type')
return class_.deserialize(self, **repr_)

serializable = class_.deserialize(self, **repr_)

if 'identifier' in repr_:
identifier = repr_['identifier']
self.__subpulses[identifier] = self.__FileEntry(repr_, serializable)
return serializable


class ExtendedJSONEncoder(json.JSONEncoder):
Expand Down

0 comments on commit a62d6dd

Please sign in to comment.