Takes an operator and params and creates an instance of that operator.

        :returns: instance of operator object
494397
def make_task(operator: str, task_params: Dict[str, Any]) -> BaseOperator:
        
        try:
            # class is a Callable https://stackoverflow.com/a/34578836/3679900
            operator_obj: Callable[..., BaseOperator] = import_string(operator)
        except Exception as e:
            raise Exception(f"Failed to import operator: {operator}. err: {e}")
        try:
            task: BaseOperator = operator_obj(**task_params)
        except Exception as e:
            raise Exception(f"Failed to create {operator_obj} task. err: {e}")
        return task
340283
def build_binary_op(self, op, other):
        
        if isinstance(other, NumericalExpression):
            self_expr, other_expr, new_inputs = self._merge_expressions(other)
        elif isinstance(other, Term):
            self_expr = self._expr
            new_inputs, other_idx = _ensure_element(self.inputs, other)
            other_expr = "x_%d" % other_idx
        elif isinstance(other, Number):
            self_expr = self._expr
            other_expr = str(other)
            new_inputs = self.inputs
        else:
            raise BadBinaryOperator(op, other)
        return self_expr, other_expr, new_inputs
229620
def get_constructor(self):
        
        if self.parameters:
            return lambda *params: lambda *qubits: \
                Gate(name=self.name, params=list(params), qubits=list(map(unpack_qubit, qubits)))
        else:
            return lambda *qubits: Gate(name=self.name, params=[], qubits=list(map(unpack_qubit, qubits)))
1069528
def _modifier(self, operator, params):
        ''' 
        
        '''

        if operator == '$orderby':
            order_types = {-1: 'DESC', 1: 'ASC'}
            if not isinstance(params, dict):
                raise RuntimeError('Incorrect parameter type, %s' % params) 
            return 'ORDER BY %s' % ','.join(["%s %s" % (p, order_types[params[p]]) for p in params])
        else:
            raise RuntimeError('Unknown operator, %s' % operator)
907635
def run_operator(operator, revision, config):
    """"""
    instance = operator.cls(config)
    logger.debug(f"Running {operator.name} operator on {revision.key}")
    return operator.name, instance.run(revision, config)
1119451
def SetOperator(self, operator):
    """"""
    self.operator = operator
    # Find the appropriate list of operators for this attribute
    attribute_type = self.attribute_obj.GetRDFValueType()
    operators = attribute_type.operators

    # Do we have such an operator?
    self.number_of_args, self.operator_method = operators.get(
        operator, (0, None))

    if self.operator_method is None:
      raise lexer.ParseError("Operator %s not defined on attribute '%s'" %
                             (operator, self.attribute))

    self.operator_method = getattr(attribute_type, self.operator_method)
276965
def comparator(operator):
    
    @wraps(operator)
    def wrapper(self, other):
        if not isinstance(other, (VersionInfo, dict)):
            return NotImplemented
        return operator(self, other)
    return wrapper
905717
def operators(self, ignore=0):
        
        return [k for k, v in self._operatorMap.items() if not v.flags & ignore]
265053
def properties_operator(cls, name):
    """"""

    def wrapper(self, *args, **kwargs):
        """Perform operation and cast to container class"""
        output = getattr(super(cls, self), name)(*args, **kwargs)
        return cls(output)

    wrapped = getattr(cls, name)
    wrapper.__name__ = wrapped.__name__
    wrapper.__doc__ = wrapped.__doc__
    return wrapper
220446
def operator_same_class(method):
    
    def wrapper(self, other):
        if not isinstance(other, self.__class__):
            raise TypeError(
                'unsupported operand types: \'{0}\' and \'{1}\''.format(
                    self.__class__.__name__, other.__class__.__name__))
        return method(self, other)
    return wrapper
285517
def _operator_generator(index, conj):
        
        pterm = PauliTerm('I', 0, 1.0)
        Zstring = PauliTerm('I', 0, 1.0)
        for j in range(index):
            Zstring = Zstring*PauliTerm('Z', j, 1.0)

        pterm1 = Zstring*PauliTerm('X', index, 0.5)
        scalar = 0.5 * conj * 1.0j
        pterm2 = Zstring*PauliTerm('Y', index, scalar)
        pterm = pterm * (pterm1 + pterm2)

        pterm = pterm.simplify()
        return pterm
445668
def get_lookup(self, operator):
        
        try:
            return self._lookups[operator]
        except KeyError:
            raise NotImplementedError("Lookup operator '{}' is not supported".format(operator))
156965
def _make_expr_ops(self, op_list, op_dict=None, op_class=None):
        
        for o in op_list:
            if op_dict is not None:
                if o in op_dict:
                    self._op_expr[o] = op_dict[o]
                else:
                    l.warning("Operation %s not in op_dict.", o)
            else:
                if hasattr(op_class, o):
                    self._op_expr[o] = getattr(op_class, o)
                else:
                    l.warning("Operation %s not in op_class %s.", o, op_class)
865027
def _param(self):
        
        class Parameters(object):
            def __getitem__(_self, name):
                return self.getParameter(name)

            def __setitem__(_self, name, value):
                if isinstance(value, (float, int, basestring)):
                    self.getParameter(name).set(value)
                else:
                    self.getParameter(name).setValues(value)

            def __iter__(_self):
                return self.getParameters()

        return Parameters()
963562
def passing(self, *args, **kwargs):
        
        self.args = args
        self.kwargs = kwargs
        return self
51613
def instantiate(self):
        
        if self.instance is None:
            self.instance = checked_call(self.cls, self.kwds)
        #endif
        try:
            self.instance.yaml_src = self.yaml_src
        except AttributeError:
            pass
        return self.instance
988387
def to_op(self):
        
        if not self._adds and not self._removes:
            return None
        changes = {}
        if self._adds:
            changes['adds'] = list(self._adds)
        if self._removes:
            changes['removes'] = list(self._removes)
        return changes