Пример #1
0
    def __init__(self,
                 *schedules: Union[Union['Schedule', Instruction],
                                   Tuple[int, Union['Schedule', Instruction]]],
                 name: Optional[str] = None):
        """Create an empty schedule.

        Args:
            *schedules: Child Schedules of this parent Schedule. May either be passed as
                        the list of schedules, or a list of ``(start_time, schedule)`` pairs.
            name: Name of this schedule. Defaults to an autogenerated string if not provided.
        """
        if name is None:
            name = self.prefix + str(next(self.instances_counter))
            if sys.platform != "win32" and not is_main_process():
                name += '-{}'.format(mp.current_process().pid)

        self._name = name
        self._duration = 0

        # These attributes are populated by ``_mutable_insert``
        self._timeslots = {}
        self.__children = []
        self._parameter_table = defaultdict(list)
        for sched_pair in schedules:
            try:
                time, sched = sched_pair
            except TypeError:
                # recreate as sequence starting at 0.
                time, sched = 0, sched_pair
            self._mutable_insert(time, sched)
Пример #2
0
    def __init__(self,
                 *schedules: Union[Union['Schedule', Instruction],
                                   Tuple[int, Union['Schedule', Instruction]]],
                 name: Optional[str] = None,
                 metadata: Optional[dict] = None):
        """Create an empty schedule.

        Args:
            *schedules: Child Schedules of this parent Schedule. May either be passed as
                        the list of schedules, or a list of ``(start_time, schedule)`` pairs.
            name: Name of this schedule. Defaults to an autogenerated string if not provided.
            metadata: Arbitrary key value metadata to associate with the schedule. This gets
                stored as free-form data in a dict in the
                :attr:`~qiskit.pulse.Schedule.metadata` attribute. It will not be directly
                used in the schedule.
        Raises:
            TypeError: if metadata is not a dict.
        """
        if name is None:
            name = self.prefix + str(next(self.instances_counter))
            if sys.platform != "win32" and not is_main_process():
                name += '-{}'.format(mp.current_process().pid)

        self._name = name
        self._duration = 0

        # These attributes are populated by ``_mutable_insert``
        self._timeslots = {}
        self.__children = []
        self._parameter_table = defaultdict(list)
        for sched_pair in schedules:
            try:
                time, sched = sched_pair
            except TypeError:
                # recreate as sequence starting at 0.
                time, sched = 0, sched_pair
            self._mutable_insert(time, sched)
        if not isinstance(metadata, dict) and metadata is not None:
            raise TypeError(
                "Only a dictionary or None is accepted for schedule metadata")
        self._metadata = metadata