Quanlse/QWaveform.py
def addOperators(self, operators: Union[QOperator, Callable, List[QOperator], List[Callable]],
                     onSubSys: Union[int, List[int]], name: str = None, flagDoNotClear: bool = False) -> str:
        """
        Add control terms onto the specified subsystem.

        :param operators: QOperator object(s)
        :param onSubSys: what subsystem the wave is acting upon
        :param name: user-defined operator name
        :param flagDoNotClear: whether this operator will be cleared
        """

        _operators = formatOperatorInput(operators, onSubSys, self.sysLevel)

        if _operators is not None and onSubSys is None:
            # Input the complete matrices directly.
            if isinstance(self._sysLevel, int):
                dim = self._sysLevel ** self._subSysNum
            elif isinstance(self._sysLevel, list):
                dim = 1
                for lvl in self._sysLevel:
                    dim = dim * lvl
            else:
                raise Error.ArgumentError(f"Unsupported type of self._sysLevel ({type(self._sysLevel)}).")

            if not shape(_operators.matrix) == (dim, dim):
                raise Error.ArgumentError(f"Dimension of operator ({dim}, {dim}) does not match the sysLevel.")

            operatorForSave = _operators
        else:
            # If users input the onSubSys, combineOperatorAndOnSubSys will update the onSubSys of
            #     the operators.
            operatorForSave = combineOperatorAndOnSubSys(self._subSysNum, _operators, onSubSys)

        # Set the name if it is given
        if name is not None:
            opKey = name
        else:
            # Use function generateOperatorKey to generate the key of the operators.
            opKey = generateOperatorKey(self.subSysNum, operatorForSave)

        if flagDoNotClear and self.parent is None:
            raise Error.ArgumentError("Current QJob object has no parent, hence cannot add "
                                      "waves with QWAVEFORM_FLAG_DO_NOT_CLEAR.")
        elif not flagDoNotClear:
            containerCtrlOperators = self._ctrlOperators
            containerWaves = self._waves
        else:
            containerCtrlOperators = self.parent.doNotClearFlagOperators
            containerWaves = self.parent.doNotClearFlagWaves

        # Verify the uniqueness of the combination of the name and onSubSys
        if opKey not in containerCtrlOperators.keys():
            # Save the operators.
            containerCtrlOperators[opKey] = operatorForSave
            containerWaves[opKey] = []

        # Compute the end time
        self.computeMaxTime()

        return opKey

        Add control terms onto the specified subsystem.

        :param operators: QOperator object(s)
        :param onSubSys: what subsystem the wave is acting upon
        :param name: user-defined operator name
        :param flagDoNotClear: whether this operator will be cleared
        
Add control terms onto the specified subsystem.
Add control terms onto the specified subsystem .
def addOperators(self, operators: Union[QOperator, Callable, List[QOperator], List[Callable]],
                     onSubSys: Union[int, List[int]], name: str = None, flagDoNotClear: bool = False) -> str:
        _operators = formatOperatorInput(operators, onSubSys, self.sysLevel)
        if _operators is not None and onSubSys is None:
            if isinstance(self._sysLevel, int):
                dim = self._sysLevel ** self._subSysNum
            elif isinstance(self._sysLevel, list):
                dim = 1
                for lvl in self._sysLevel:
                    dim = dim * lvl
            else:
                raise Error.ArgumentError(f"Unsupported type of self._sysLevel ({type(self._sysLevel)}).")
            if not shape(_operators.matrix) == (dim, dim):
                raise Error.ArgumentError(f"Dimension of operator ({dim}, {dim}) does not match the sysLevel.")
            operatorForSave = _operators
        else:
            operatorForSave = combineOperatorAndOnSubSys(self._subSysNum, _operators, onSubSys)
        if name is not None:
            opKey = name
        else:
            opKey = generateOperatorKey(self.subSysNum, operatorForSave)
        if flagDoNotClear and self.parent is None:
            raise Error.ArgumentError("Current QJob object has no parent, hence cannot add "
                                      "waves with QWAVEFORM_FLAG_DO_NOT_CLEAR.")
        elif not flagDoNotClear:
            containerCtrlOperators = self._ctrlOperators
            containerWaves = self._waves
        else:
            containerCtrlOperators = self.parent.doNotClearFlagOperators
            containerWaves = self.parent.doNotClearFlagWaves
        if opKey not in containerCtrlOperators.keys():
            containerCtrlOperators[opKey] = operatorForSave
            containerWaves[opKey] = []
        self.computeMaxTime()
        return opKey
def addOperators ( self , operators : Union [ QOperator , Callable , List [ QOperator ] , List [ Callable ] ] , onSubSys : Union [ int , List [ int ] ] , name : str = None , flagDoNotClear : bool = False ) -> str : _operators = formatOperatorInput ( operators , onSubSys , self . sysLevel ) if _operators is not None and onSubSys is None : if isinstance ( self . _sysLevel , int ) : dim = self . _sysLevel ** self . _subSysNum elif isinstance ( self . _sysLevel , list ) : dim = 1 for lvl in self . _sysLevel : dim = dim * lvl else : raise Error . ArgumentError ( f"Unsupported type of self._sysLevel ({type(self._sysLevel)})." ) if not shape ( _operators . matrix ) == ( dim , dim ) : raise Error . ArgumentError ( f"Dimension of operator ({dim}, {dim}) does not match the sysLevel." ) operatorForSave = _operators else : operatorForSave = combineOperatorAndOnSubSys ( self . _subSysNum , _operators , onSubSys ) if name is not None : opKey = name else : opKey = generateOperatorKey ( self . subSysNum , operatorForSave ) if flagDoNotClear and self . parent is None : raise Error . ArgumentError ( "Current QJob object has no parent, hence cannot add " "waves with QWAVEFORM_FLAG_DO_NOT_CLEAR." ) elif not flagDoNotClear : containerCtrlOperators = self . _ctrlOperators containerWaves = self . _waves else : containerCtrlOperators = self . parent . doNotClearFlagOperators containerWaves = self . parent . doNotClearFlagWaves if opKey not in containerCtrlOperators . keys ( ) : containerCtrlOperators [ opKey ] = operatorForSave containerWaves [ opKey ] = [ ] self . computeMaxTime ( ) return opKey
Add control terms onto the specified subsystem.
Add control terms onto the specified subsystem .
"""
        Add control terms onto the specified subsystem.

        :param operators: QOperator object(s)
        :param onSubSys: what subsystem the wave is acting upon
        :param name: user-defined operator name
        :param flagDoNotClear: whether this operator will be cleared
        """ # Input the complete matrices directly. # If users input the onSubSys, combineOperatorAndOnSubSys will update the onSubSys of #     the operators. # Set the name if it is given # Use function generateOperatorKey to generate the key of the operators. # Verify the uniqueness of the combination of the name and onSubSys # Save the operators. # Compute the end time
self
operators
Union[QOperator, Callable, List[QOperator], List[Callable]]
None
onSubSys
Union[int, List[int]]
None
name
str
user-defined operator name
user - defined operator name
flagDoNotClear
bool
whether this operator will be cleared
whether this operator will be cleared