diff --git a/qiskit/circuit/library/data_preparation/state_preparation.py b/qiskit/circuit/library/data_preparation/state_preparation.py index 5c295bb6635..7c3ff7a61a2 100644 --- a/qiskit/circuit/library/data_preparation/state_preparation.py +++ b/qiskit/circuit/library/data_preparation/state_preparation.py @@ -490,7 +490,7 @@ def __init__( raise ValueError( "num_qubits must be an integer greater than or equal to log2(M)." ) - self.M = M + self._M = M self._num_qubits = self._get_num_qubits(num_qubits, params) def _define(self): @@ -503,7 +503,7 @@ def _define(self): qreg = QuantumRegister(self.num_qubits(), "q") qc = QuantumCircuit(self.num_qubits()) - M = self.M + M = self.M() num_qubits = self.num_qubits() if (M & (M - 1)) == 0: # if M is an integer power of 2 @@ -538,7 +538,7 @@ def num_qubits(self): def __repr__(self): """Returns a string representation of the gate.""" - return f"Generalized_Uniform_Superposition_Gate(M={self.M}, num_qubits={self._num_qubits})" + return f"Generalized_Uniform_Superposition_Gate(M={self.M()}, num_qubits={self._num_qubits})" def broadcast_arguments(self, qargs, cargs): """Validates and handles the arguments."""