def _append_instruction(self, obj, qargs=None):
if isinstance(obj, Instruction):<EOL><INDENT>mat = None<EOL>if hasattr(obj, '<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>mat = obj.to_matrix()<EOL><DEDENT>except QiskitError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if mat is not None:<EOL><INDENT>op = self.compose(mat, qargs=qargs)<EOL>self._data = op.data<EOL><DEDENT>else:<EOL><INDENT>if obj.definition is None:<EOL><INDENT>raise QiskitError('<STR_LIT>'.format(obj.name))<EOL><DEDENT>for instr, qregs, cregs in obj.definition:<EOL><INDENT>if cregs:<EOL><INDENT>raise QiskitError(<EOL>'<STR_LIT>'.format(<EOL>instr.name))<EOL><DEDENT>new_qargs = [tup[<NUM_LIT:1>] for tup in qregs]<EOL>self._append_instruction(instr, qargs=new_qargs)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise QiskitError('<STR_LIT>')<EOL><DEDENT>
Update the current Operator by apply an instruction.