Repository: Qiskit/qiskit

Issue:
equality of instruction initialize does not work
### Information

- **Qiskit Terra version**:
- **Python version**:
- **Operating system**:

### What is the current behavior?

When compare two circuits with `initialize`, equality fails when it should not.

```python
from qiskit import QuantumRegister, QuantumCircuit
init_vector = [0.5, 0.5, 0.5, 0.5]
qreg = QuantumRegister(2)

circuit1 = QuantumCircuit(qreg, name='circuit')
circuit1.initialize(init_vector, [qreg[0], qreg[1]])

circuit2 = QuantumCircuit(qreg, name='circuit')
circuit2.initialize(init_vector, [qreg[0], qreg[1]])

print(circuit1)
print(circuit2)

assert circuit1 == circuit2
```

### What is the expected behavior?

Same as other gates, `initialize` should support equality as other gates.



Discussion:

Resolving patch:
diff --git a/qiskit/extensions/quantum_initializer/initializer.py b/qiskit/extensions/quantum_initializer/initializer.py
--- a/qiskit/extensions/quantum_initializer/initializer.py
+++ b/qiskit/extensions/quantum_initializer/initializer.py
@@ -69,8 +69,8 @@ def _define(self):
         # the qubits are in the zero state)
         initialize_gate = disentangling_circuit.to_instruction().inverse()
 
-        q = QuantumRegister(self.num_qubits)
-        initialize_circuit = QuantumCircuit(q)
+        q = QuantumRegister(self.num_qubits, 'q')
+        initialize_circuit = QuantumCircuit(q, name='init_def')
         # TODO: make initialize an Instruction, and insert reset
         # TODO: avoid explicit reset if compiler determines a |0> state
         initialize_circuit.append(initialize_gate, q[:])
@@ -86,7 +86,7 @@ def gates_to_uncompute(self):
             QuantumCircuit: circuit to take self.params vector to |00..0>
         """
         q = QuantumRegister(self.num_qubits)
-        circuit = QuantumCircuit(q)
+        circuit = QuantumCircuit(q, name='disentangler')
 
         # kick start the peeling loop, and disentangle one-by-one from LSB to MSB
         remaining_param = self.params
@@ -192,8 +192,7 @@ def _multiplex(self, target_gate, list_of_angles):
         local_num_qubits = int(math.log2(list_len)) + 1
 
         q = QuantumRegister(local_num_qubits)
-        circuit = QuantumCircuit(q)
-        circuit.name = "multiplex" + local_num_qubits.__str__()
+        circuit = QuantumCircuit(q, name="multiplex"+local_num_qubits.__str__())
 
         lsb = q[0]
         msb = q[local_num_qubits - 1]


Test patch:
diff --git a/test/python/circuit/test_initializer.py b/test/python/circuit/test_initializer.py
--- a/test/python/circuit/test_initializer.py
+++ b/test/python/circuit/test_initializer.py
@@ -276,6 +276,19 @@ def test_combiner(self):
             fidelity, self._desired_fidelity,
             "Initializer has low fidelity {0:.2g}.".format(fidelity))
 
+    def test_equivalence(self):
+        """Test two similar initialize instructions evaluate to equal."""
+        desired_vector = [0.5, 0.5, 0.5, 0.5]
+        qr = QuantumRegister(2, "qr")
+
+        qc1 = QuantumCircuit(qr, name='circuit')
+        qc1.initialize(desired_vector, [qr[0], qr[1]])
+
+        qc2 = QuantumCircuit(qr, name='circuit')
+        qc2.initialize(desired_vector, [qr[0], qr[1]])
+
+        self.assertEqual(qc1, qc2)
+
 
 if __name__ == '__main__':
     unittest.main()