def get_channel(self, channel): """Parse and retrieve channel from ch string. Args: channel (str): Channel to match Returns: (Channel, int): Matched channel Raises: PulseError: Is raised if valid channel is not matched """ match = self.chan_regex.match(channel) if match: prefix, index = match.group(1), int(match.group(2)) if prefix == channels.DriveChannel.prefix: return channels.DriveChannel(index, buffer=self.buffer) elif prefix == channels.MeasureChannel.prefix: return channels.MeasureChannel(index, buffer=self.buffer) elif prefix == channels.ControlChannel.prefix: return channels.ControlChannel(index, buffer=self.buffer) raise PulseError('Channel %s is not valid' % channel)
def get_channel(self, channel: str) -> channels.PulseChannel: """Parse and retrieve channel from ch string. Args: channel: Channel to match Returns: Matched channel Raises: QiskitError: Is raised if valid channel is not matched """ match = self.chan_regex.match(channel) if match: prefix, index = match.group(1), int(match.group(2)) if prefix == channels.DriveChannel.prefix: return channels.DriveChannel(index) elif prefix == channels.MeasureChannel.prefix: return channels.MeasureChannel(index) elif prefix == channels.ControlChannel.prefix: return channels.ControlChannel(index) raise QiskitError("Channel %s is not valid" % channel)