def get_time_evolution(self):
        """Get the function to append the time evolution of this term.

        Returns:
            function(circuit: Circuit, t: float):
                Add gates for time evolution to `circuit` with time `t`
        """
        term = self.simplify()
        coeff = term.coeff
        if coeff.imag:
            raise ValueError("Not a real coefficient.")
        ops = term.ops
        def append_to_circuit(circuit, t):
            if not ops:
                return
            for op in ops:
                n = op.n
                if op.op == "X":
                    circuit.h[n]
                elif op.op == "Y":
                    circuit.rx(-half_pi)[n]
            for i in range(1, len(ops)):
                circuit.cx[ops[i-1].n, ops[i].n]
            circuit.rz(-2 * coeff * t)[ops[-1].n]
            for i in range(len(ops)-1, 0, -1):
                circuit.cx[ops[i-1].n, ops[i].n]
            for op in ops:
                n = op.n
                if op.op == "X":
                    circuit.h[n]
                elif op.op == "Y":
                    circuit.rx(half_pi)[n]
        return append_to_circuit
def get_time_evolution ( self ) : term = self . simplify ( ) coeff = term . coeff if coeff . imag : raise ValueError ( "Not a real coefficient." ) ops = term . ops def append_to_circuit ( circuit , t ) : if not ops : return for op in ops : n = op . n if op . op == "X" : circuit . h [ n ] elif op . op == "Y" : circuit . rx ( - half_pi ) [ n ] for i in range ( 1 , len ( ops ) ) : circuit . cx [ ops [ i - 1 ] . n , ops [ i ] . n ] circuit . rz ( - 2 * coeff * t ) [ ops [ - 1 ] . n ] for i in range ( len ( ops ) - 1 , 0 , - 1 ) : circuit . cx [ ops [ i - 1 ] . n , ops [ i ] . n ] for op in ops : n = op . n if op . op == "X" : circuit . h [ n ] elif op . op == "Y" : circuit . rx ( half_pi ) [ n ] return append_to_circuit
Get the function to append the time evolution of this term.

        Returns:
            function(circuit: Circuit, t: float):
                Add gates for time evolution to `circuit` with time `t`