Quanlse/Utils/Functions.py
def formatOperatorInput(operators: Union[QOperator, Callable, List[QOperator], List[Callable]],
                        onSubSys: Union[int, List[int]], sysLevel: Union[int, List[int]]) -> Union:
    """
    We allow input the Callable QOperator instances or the function.
    """
    _operators = []
    if isinstance(operators, list):
        for opIdx, op in enumerate(operators):
            if isinstance(op, QOperator):
                # Input operator is an QOperator instance
                _operators.append(copy.deepcopy(op))
            else:
                # Input operator is callable
                if isinstance(sysLevel, list):
                    _operators.append(op(sysLevel[onSubSys[opIdx]]))
                else:
                    _operators.append(op(sysLevel))
    else:
        if isinstance(operators, QOperator):
            # Input operator is an QOperator instance
            _operators = copy.deepcopy(operators)
        else:
            # Input operator is callable
            if isinstance(sysLevel, list):
                _operators = operators(sysLevel[onSubSys])
            else:
                _operators = operators(sysLevel)
    return _operators

    We allow input the Callable QOperator instances or the function.
    
We allow input the Callable QOperator instances or the function.
We allow input the Callable QOperator instances or the function .
def formatOperatorInput(operators: Union[QOperator, Callable, List[QOperator], List[Callable]],
                        onSubSys: Union[int, List[int]], sysLevel: Union[int, List[int]]) -> Union:
    _operators = []
    if isinstance(operators, list):
        for opIdx, op in enumerate(operators):
            if isinstance(op, QOperator):
                _operators.append(copy.deepcopy(op))
            else:
                if isinstance(sysLevel, list):
                    _operators.append(op(sysLevel[onSubSys[opIdx]]))
                else:
                    _operators.append(op(sysLevel))
    else:
        if isinstance(operators, QOperator):
            _operators = copy.deepcopy(operators)
        else:
            if isinstance(sysLevel, list):
                _operators = operators(sysLevel[onSubSys])
            else:
                _operators = operators(sysLevel)
    return _operators
def formatOperatorInput ( operators : Union [ QOperator , Callable , List [ QOperator ] , List [ Callable ] ] , onSubSys : Union [ int , List [ int ] ] , sysLevel : Union [ int , List [ int ] ] ) -> Union : _operators = [ ] if isinstance ( operators , list ) : for opIdx , op in enumerate ( operators ) : if isinstance ( op , QOperator ) : _operators . append ( copy . deepcopy ( op ) ) else : if isinstance ( sysLevel , list ) : _operators . append ( op ( sysLevel [ onSubSys [ opIdx ] ] ) ) else : _operators . append ( op ( sysLevel ) ) else : if isinstance ( operators , QOperator ) : _operators = copy . deepcopy ( operators ) else : if isinstance ( sysLevel , list ) : _operators = operators ( sysLevel [ onSubSys ] ) else : _operators = operators ( sysLevel ) return _operators
We allow input the Callable QOperator instances or the function.
We allow input the Callable QOperator instances or the function .
"""
    We allow input the Callable QOperator instances or the function.
    """ # Input operator is an QOperator instance # Input operator is callable # Input operator is an QOperator instance # Input operator is callable
operators
Union[QOperator, Callable, List[QOperator], List[Callable]]
onSubSys
Union[int, List[int]]
sysLevel
Union[int, List[int]]