Repository: Qiskit/qiskit

Issue:
circuit.cnot does not draw correctly
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information
IQX 2020/07/15

Qiskit Software | Version
-- | --
Qiskit | None
Terra | 0.9.0
Aer | 0.3.0
Ignis | 0.2.0
Aqua | 0.5.6
IBM Q Provider | 0.3.1

Python | 3.7.3 (default, Mar 27 2019, 16:54:48)  [Clang 4.0.1 (tags/RELEASE_401/final)]
OS | Darwin
CPUs | 4
Memory (Gb) | 16.0
Fri Aug 09 11:31:26 2019 EDT

*:

### What is the current behavior?

circ = QuantumCircuit(3)
circ.h(0)
circ.cnot(0,1)
circ.draw()

gives the error:
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-52-630ff5a5a391> in <module>
      1 circ = QuantumCircuit(3)
      2 circ.h(0)
----> 3 circ.cnot(0,1)
      4 circ.draw()

/opt/conda/lib/python3.7/site-packages/qiskit/util.py in wrapper(*args, **kwargs)
    107             if kwargs:
    108                 _rename_kwargs(func.__name__, kwargs, kwarg_map)
--> 109             return func(*args, **kwargs)
    110         return wrapper
    111     return decorator

/opt/conda/lib/python3.7/site-packages/qiskit/circuit/quantumcircuit.py in cnot(self, control_qubit, target_qubit, label, ctrl_state, ctl, tgt)
   1815              ctl=None, tgt=None):  # pylint: disable=unused-argument
   1816         """Apply :class:`~qiskit.circuit.library.CXGate`."""
-> 1817         self.cx(control_qubit, target_qubit, ctl=ctl, tgt=tgt)
   1818 
   1819     def dcx(self, qubit1, qubit2):

/opt/conda/lib/python3.7/site-packages/qiskit/util.py in wrapper(*args, **kwargs)
    107             if kwargs:
    108                 _rename_kwargs(func.__name__, kwargs, kwarg_map)
--> 109             return func(*args, **kwargs)
    110         return wrapper
    111     return decorator

TypeError: cx() got multiple values for argument 'control_qubit'

### Steps to reproduce the problem

see above

### What is the expected behavior?


should be equiv to above with circ.cx(0,1)

### Suggested solutions
Looks like a bug from the argument name change.


Discussion:

Resolving patch:
diff --git a/qiskit/circuit/quantumcircuit.py b/qiskit/circuit/quantumcircuit.py
--- a/qiskit/circuit/quantumcircuit.py
+++ b/qiskit/circuit/quantumcircuit.py
@@ -2036,7 +2036,7 @@ def cx(self, control_qubit, target_qubit, *, label=None, ctrl_state=None,
     def cnot(self, control_qubit, target_qubit, *, label=None, ctrl_state=None,
              ctl=None, tgt=None):  # pylint: disable=unused-argument
         """Apply :class:`~qiskit.circuit.library.CXGate`."""
-        self.cx(control_qubit, target_qubit, ctl=ctl, tgt=tgt)
+        self.cx(control_qubit, target_qubit)
 
     def dcx(self, qubit1, qubit2):
         """Apply :class:`~qiskit.circuit.library.DCXGate`."""


Test patch:
diff --git a/test/python/circuit/test_circuit_operations.py b/test/python/circuit/test_circuit_operations.py
--- a/test/python/circuit/test_circuit_operations.py
+++ b/test/python/circuit/test_circuit_operations.py
@@ -530,6 +530,15 @@ def test_reverse_bits_with_registers(self):
 
         self.assertEqual(qc.reverse_bits(), expected)
 
+    def test_cnot_alias(self):
+        """Test that the cnot method alias adds a cx gate."""
+        qc = QuantumCircuit(2)
+        qc.cnot(0, 1)
+
+        expected = QuantumCircuit(2)
+        expected.cx(0, 1)
+        self.assertEqual(qc, expected)
+
 
 class TestCircuitBuilding(QiskitTestCase):
     """QuantumCircuit tests."""