Quanlse/QWaveform.py
def clearWaves(self, operators: Union[QOperator, Callable, List[QOperator], List[Callable]] = None,
                   onSubSys: Union[int, List[int]] = None, names: Union[str, List[str]] = None,
                   tag: str = None) -> None:
        """
        Remove all waveforms in the specified control terms.
        If no names are given, remove all waveforms in all control terms.

        :param operators: the operator of the wave
        :param onSubSys: the subsystem of the wave
        :param names: the name of control term
        :param tag: the tag of the waves
        :return: None
        """
        # Generate opKeys of the waveforms which are going to be cleared
        if names is not None:
            # Set the name if it is given
            opKey = names
        elif operators is not None and onSubSys is not None:
            _operators = formatOperatorInput(operators, onSubSys, self.sysLevel)
            # If users input the onSubSys, combineOperatorAndOnSubSys will update the onSubSys of
            #     the operators.
            operatorForSave = combineOperatorAndOnSubSys(self._subSysNum, _operators, onSubSys)
            # Use function generateOperatorKey to generate the key of the operators.
            if isinstance(_operators, list):
                opKey = []
                for op in _operators:
                    opKey.append(generateOperatorKey(self.subSysNum, op))
            else:
                opKey = generateOperatorKey(self.subSysNum, operatorForSave)
        else:
            # Remove all waveforms
            opKey = self._ctrlOperators.keys()

        # Generate opKeys of the waveforms which are going to be cleared
        tagBlackList = []
        if tag is not None:
            if isinstance(tag, list):
                tagBlackList.extend(tag)
            else:
                tagBlackList.append(tag)

        # Generate new wave list
        newWaves = {}
        newCtrlOperators = {}
        for key in self._waves.keys():
            _toSave = []
            for wave in self._waves[key]:
                _ifSave = False
                # Check flag QWAVEFORM_DO_NOT_CLEAR
                _ifSave = _ifSave or ((wave.flag & QWAVEFORM_FLAG_DO_NOT_CLEAR) > 0)
                # Check opKey
                _ifSave = _ifSave or (key not in opKey)
                # Check tag
                _ifSave = _ifSave or (len(tagBlackList) > 0 and wave.tag not in tagBlackList)
                if _ifSave:
                    _toSave.append(copy.deepcopy(wave))
            if len(_toSave) > 0:
                newWaves[key] = _toSave
                newCtrlOperators[key] = copy.deepcopy(self._ctrlOperators[key])

        del self._waves
        del self._ctrlOperators
        self._waves = newWaves
        self._ctrlOperators = newCtrlOperators
        self.computeMaxTime()

        Remove all waveforms in the specified control terms.
        If no names are given, remove all waveforms in all control terms.

        :param operators: the operator of the wave
        :param onSubSys: the subsystem of the wave
        :param names: the name of control term
        :param tag: the tag of the waves
        :return: None
        
Remove all waveforms in the specified control terms.
If no names are given, remove all waveforms in all control terms.
Remove all waveforms in the specified control terms . If no names are given remove all waveforms in all control terms .
def clearWaves(self, operators: Union[QOperator, Callable, List[QOperator], List[Callable]] = None,
                   onSubSys: Union[int, List[int]] = None, names: Union[str, List[str]] = None,
                   tag: str = None) -> None:
        if names is not None:
            opKey = names
        elif operators is not None and onSubSys is not None:
            _operators = formatOperatorInput(operators, onSubSys, self.sysLevel)
            operatorForSave = combineOperatorAndOnSubSys(self._subSysNum, _operators, onSubSys)
            if isinstance(_operators, list):
                opKey = []
                for op in _operators:
                    opKey.append(generateOperatorKey(self.subSysNum, op))
            else:
                opKey = generateOperatorKey(self.subSysNum, operatorForSave)
        else:
            opKey = self._ctrlOperators.keys()
        tagBlackList = []
        if tag is not None:
            if isinstance(tag, list):
                tagBlackList.extend(tag)
            else:
                tagBlackList.append(tag)
        newWaves = {}
        newCtrlOperators = {}
        for key in self._waves.keys():
            _toSave = []
            for wave in self._waves[key]:
                _ifSave = False
                _ifSave = _ifSave or ((wave.flag & QWAVEFORM_FLAG_DO_NOT_CLEAR) > 0)
                _ifSave = _ifSave or (key not in opKey)
                _ifSave = _ifSave or (len(tagBlackList) > 0 and wave.tag not in tagBlackList)
                if _ifSave:
                    _toSave.append(copy.deepcopy(wave))
            if len(_toSave) > 0:
                newWaves[key] = _toSave
                newCtrlOperators[key] = copy.deepcopy(self._ctrlOperators[key])
        del self._waves
        del self._ctrlOperators
        self._waves = newWaves
        self._ctrlOperators = newCtrlOperators
        self.computeMaxTime()
def clearWaves ( self , operators : Union [ QOperator , Callable , List [ QOperator ] , List [ Callable ] ] = None , onSubSys : Union [ int , List [ int ] ] = None , names : Union [ str , List [ str ] ] = None , tag : str = None ) -> None : if names is not None : opKey = names elif operators is not None and onSubSys is not None : _operators = formatOperatorInput ( operators , onSubSys , self . sysLevel ) operatorForSave = combineOperatorAndOnSubSys ( self . _subSysNum , _operators , onSubSys ) if isinstance ( _operators , list ) : opKey = [ ] for op in _operators : opKey . append ( generateOperatorKey ( self . subSysNum , op ) ) else : opKey = generateOperatorKey ( self . subSysNum , operatorForSave ) else : opKey = self . _ctrlOperators . keys ( ) tagBlackList = [ ] if tag is not None : if isinstance ( tag , list ) : tagBlackList . extend ( tag ) else : tagBlackList . append ( tag ) newWaves = { } newCtrlOperators = { } for key in self . _waves . keys ( ) : _toSave = [ ] for wave in self . _waves [ key ] : _ifSave = False _ifSave = _ifSave or ( ( wave . flag & QWAVEFORM_FLAG_DO_NOT_CLEAR ) > 0 ) _ifSave = _ifSave or ( key not in opKey ) _ifSave = _ifSave or ( len ( tagBlackList ) > 0 and wave . tag not in tagBlackList ) if _ifSave : _toSave . append ( copy . deepcopy ( wave ) ) if len ( _toSave ) > 0 : newWaves [ key ] = _toSave newCtrlOperators [ key ] = copy . deepcopy ( self . _ctrlOperators [ key ] ) del self . _waves del self . _ctrlOperators self . _waves = newWaves self . _ctrlOperators = newCtrlOperators self . computeMaxTime ( )
Remove all waveforms in the specified control terms.
Remove all waveforms in the specified control terms .
"""
        Remove all waveforms in the specified control terms.
        If no names are given, remove all waveforms in all control terms.

        :param operators: the operator of the wave
        :param onSubSys: the subsystem of the wave
        :param names: the name of control term
        :param tag: the tag of the waves
        :return: None
        """ # Generate opKeys of the waveforms which are going to be cleared # Set the name if it is given # If users input the onSubSys, combineOperatorAndOnSubSys will update the onSubSys of #     the operators. # Use function generateOperatorKey to generate the key of the operators. # Remove all waveforms # Generate opKeys of the waveforms which are going to be cleared # Generate new wave list # Check flag QWAVEFORM_DO_NOT_CLEAR # Check opKey # Check tag
None
self
operators
Union[QOperator, Callable, List[QOperator], List[Callable]]
the operator of the wave
the operator of the wave
onSubSys
Union[int, List[int]]
the subsystem of the wave
the subsystem of the wave
names
Union[str, List[str]]
the name of control term
the name of control term
tag
str
the tag of the waves
the tag of the waves