def start_gate(self, name, args, qubits, nested_scope=None): """Begin a custom gate. name is name string. args is list of Node expression objects. qubits is list of (regname, idx) tuples. nested_scope is a list of dictionaries mapping expression variables to Node expression objects in order of increasing nesting depth. """ if self.listen and name not in self.basis \ and self.gates[name]["opaque"]: raise BackendError("opaque gate %s not in basis" % name) if self.listen and name in self.basis: self.in_gate = name self.listen = False qubit_indices = [self._qubit_order_internal.get(qubit) for qubit in qubits] self.circuit['instructions'].append({ 'name': name, # TODO: keep these real for now, until a later time 'params': list(map(lambda x: float(x.real(nested_scope)), args)), 'texparams': list(map(lambda x: x.latex(prec=8, nested_scope=nested_scope), args)), 'qubits': qubit_indices, }) self._add_condition()
def start_gate(self, name, args, qubits, nested_scope=None, extra_fields=None): if self.listen and name not in self.basis \ and self.gates[name]["opaque"]: raise BackendError("opaque gate %s not in basis" % name) if self.listen and name in self.basis: self.in_gate = name self.listen = False qubit_indices = [ self._qubit_order_internal.get(qubit) for qubit in qubits ] gate_instruction = { 'name': name, # TODO: keep these real for now, until a later time 'params': list(map(lambda x: float(x.real(nested_scope)), args)), 'texparams': list( map(lambda x: x.latex(prec=8, nested_scope=nested_scope), args)), 'qubits': qubit_indices, } if extra_fields is not None: gate_instruction.update(extra_fields) self.circuit['instructions'].append(gate_instruction) self._add_condition()