Skip to content

Commit

Permalink
Update state_preparation.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Hirmay authored Apr 10, 2024
1 parent 9ab85f5 commit 1bdecac
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions qiskit/circuit/library/data_preparation/state_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,11 @@ def _define(self):
Returns:
QuantumCircuit: The quantum circuit implementing the gate.
"""
qreg = QuantumRegister(self.num_qubits, "q")
qc = QuantumCircuit(self.num_qubits)
qreg = QuantumRegister(self._num_qubits, "q")
qc = QuantumCircuit(self._num_qubits)

M = self.M
num_qubits = self.num_qubits
M = self._M
num_qubits = self._num_qubits

if (M & (M - 1)) == 0: # if M is an integer power of 2
m = int(np.log2(M))
Expand Down Expand Up @@ -534,11 +534,11 @@ def _define(self):

return qc

def M(self):
def _get_M(self):
"""Returns the M value used by the gate"""
return self._M

def num_qubits(self):
def _get_num_qubits(self):
"""Returns the number of qubits used by the gate."""
return self._num_qubits

Expand All @@ -550,9 +550,9 @@ def broadcast_arguments(self, qargs, cargs):
"""Validates and handles the arguments."""
flat_qargs = [qarg for sublist in qargs for qarg in sublist]

if self.num_qubits != len(flat_qargs):
if self._num_qubits != len(flat_qargs):
raise CircuitError(
f"Generalized_Uniform_Superposition_Gate expects {self.num_qubits} qubits, but {len(flat_qargs)} were provided."
f"Generalized_Uniform_Superposition_Gate expects {self._num_qubits} qubits, but {len(flat_qargs)} were provided."
)
yield flat_qargs, []

Expand All @@ -576,6 +576,6 @@ def to_instruction(self):

def to_unitary(self):
instruction = self.to_instruction()
qc = QuantumCircuit(self.num_qubits)
qc.append(instruction, list(range(self.num_qubits)))
qc = QuantumCircuit(self._num_qubits)
qc.append(instruction, list(range(self._num_qubits)))
return np.array(Operator(qc).data)

0 comments on commit 1bdecac

Please sign in to comment.