Ejemplo n.º 1
0
 def assemble(self):
     """Assemble a QasmQobjInstruction"""
     instruction = QasmQobjInstruction(name=self.name, validate=False)
     # Evaluate parameters
     if self.params:
         params = [
             x.evalf(x) if hasattr(x, 'evalf') else x for x in self.params]
         instruction.params = params
     # Add placeholder for qarg and carg params
     if self.num_qubits:
         instruction.qubits = list(range(self.num_qubits))
     if self.num_clbits:
         instruction.memory = list(range(self.num_clbits))
     # Add condition parameters for assembler. This is needed to convert
     # to a qobj conditional instruction at assemble time and after
     # conversion will be deleted by the assembler.
     if self.condition:
         instruction._condition = self.condition
     return instruction
Ejemplo n.º 2
0
 def assemble(self):
     """Assemble a QasmQobjInstruction"""
     instruction = QasmQobjInstruction(name=self.name)
     # Evaluate parameters
     if self.params:
         params = [
             x.evalf() if hasattr(x, 'evalf') else x for x in self.params
         ]
         params = [
             sympy.matrix2numpy(x, dtype=complex) if isinstance(
                 x, sympy.Matrix) else x for x in params
         ]
         instruction.params = params
     # Add placeholder for qarg and carg params
     if self.num_qubits:
         instruction.qubits = list(range(self.num_qubits))
     if self.num_clbits:
         instruction.memory = list(range(self.num_clbits))
     # Add control parameters for assembler. This is needed to convert
     # to a qobj conditional instruction at assemble time and after
     # conversion will be deleted by the assembler.
     if self.control:
         instruction._control = self.control
     return instruction