def __repr__(self): def repr_gate(gate): name, inputs = gate.op.type.name, gate.op.params + [ x.index[0] for x in gate.qubits + gate.bits ] return "{}({})".format(name, ", ".join(map(str, inputs))) init = [ "tk.Circuit({}{})".format( self.n_qubits, ", {}".format(len(self.bits)) if self.bits else "") ] gates = list(map(repr_gate, list(self))) post_select = ["post_select({})".format(self.post_selection)]\ if self.post_selection else [] scalar = [ "scale({})".format(format_number(x)) for x in [self.scalar] if x != 1 ] post_process = [ "post_process({})".format(repr(d)) for d in [self.post_processing] if d ] return '.'.join(init + gates + post_select + scalar + post_process)
def name(self): return "scalar({})".format(format_number(self.data))
def __init__(self, data): super().__init__("scalar", PRO(0), PRO(0), data=data) self.drawing_name = format_number(data)
def name(self): return "{}({}, {}{})".format( self._name, len(self.dom), len(self.cod), ", {}".format(format_number(self.phase)) if self.phase else "")