Fixed loading and saving of sequences.

This commit is contained in:
jupfi 2024-05-29 16:12:07 +02:00
parent a4a573c6e3
commit b9cacb0d30
2 changed files with 8 additions and 5 deletions

View file

@ -46,7 +46,7 @@ class Event:
) )
@classmethod @classmethod
def load_event(cls, event, pulse_parameter_options): def load_event(cls, event, pulse_sequence):
"""Loads an event from a dict. """Loads an event from a dict.
The pulse paramter options are needed to load the parameters The pulse paramter options are needed to load the parameters
@ -54,12 +54,14 @@ class Event:
Args: Args:
event (dict): The dict with the event data event (dict): The dict with the event data
pulse_parameter_options (dict): The dict with the pulse parameter options pulse_sequence (PulseSequence): The pulse sequence the event belongs to
Returns: Returns:
Event: The loaded event Event: The loaded event
""" """
obj = cls(event["name"], event["duration"]) obj = cls(event["name"], event["duration"], pulse_sequence)
pulse_parameter_options = pulse_sequence.pulse_parameter_options
for parameter in event["parameters"]: for parameter in event["parameters"]:
for pulse_parameter_option in pulse_parameter_options.keys(): for pulse_parameter_option in pulse_parameter_options.keys():
# This checks if the pulse paramter options are the same as the ones in the pulse sequence # This checks if the pulse paramter options are the same as the ones in the pulse sequence

View file

@ -118,7 +118,7 @@ class PulseSequence:
return data return data
@classmethod @classmethod
def load_sequence(cls, sequence, pulse_parameter_options): def load_sequence(cls, sequence):
"""Loads a pulse sequence from a dict. """Loads a pulse sequence from a dict.
The pulse paramter options are needed to load the parameters The pulse paramter options are needed to load the parameters
@ -141,7 +141,8 @@ class PulseSequence:
raise KeyError("Pulse sequence version not found") raise KeyError("Pulse sequence version not found")
for event_data in sequence["events"]: for event_data in sequence["events"]:
obj.events.append(cls.Event.load_event(event_data, pulse_parameter_options)) event = Event.load_event(event_data, obj)
obj.events.append(event)
return obj return obj