def x(self, q):
    'Apply X to q.'
    if isinstance(q, QuantumRegister):
        gs = InstructionSet()
        for j in range(q.size):
            gs.add(self.x((q, j)))
        return gs
    else:
        self._check_qubit(q)
        return self._attach(XGate(q, self))
Apply X to q.
def x(self, q):
    
    if isinstance(q, QuantumRegister):
        gs = InstructionSet()
        for j in range(q.size):
            gs.add(self.x((q, j)))
        return gs
    else:
        self._check_qubit(q)
        return self._attach(XGate(q, self))