Skip to content

Commit 866e1ae

Browse files
Fix Pauli.numberofqubits deprecation (qiskit-community/qiskit-aqua#881)
* Fix Pauli.numberofqubits deprecation
1 parent c1c025f commit 866e1ae

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

qiskit/aqua/operators/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# This code is part of Qiskit.
44
#
5-
# (C) Copyright IBM 2019.
5+
# (C) Copyright IBM 2019, 2020.
66
#
77
# This code is licensed under the Apache License, Version 2.0. You may
88
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -42,7 +42,7 @@ def pauli_measurement(circuit, pauli, qr, cr, barrier=False):
4242
Returns:
4343
QuantumCircuit: the original circuit object with post-rotation gate
4444
"""
45-
num_qubits = pauli.numberofqubits
45+
num_qubits = pauli.num_qubits
4646
for qubit_idx in range(num_qubits):
4747
if pauli.x[qubit_idx]:
4848
if pauli.z[qubit_idx]:
@@ -260,7 +260,7 @@ def evolution_instruction(pauli_list, evo_time, num_time_slices,
260260
if not isinstance(power, (int, np.int)) or power < 1:
261261
raise AquaError("power must be an integer and greater or equal to 1.")
262262

263-
state_registers = QuantumRegister(pauli_list[0][1].numberofqubits)
263+
state_registers = QuantumRegister(pauli_list[0][1].num_qubits)
264264
if controlled:
265265
inst_name = 'Controlled-Evolution^{}'.format(power)
266266
ancillary_registers = QuantumRegister(1)
@@ -275,7 +275,7 @@ def evolution_instruction(pauli_list, evo_time, num_time_slices,
275275
top_xyz_pauli_indices = [-1] * len(pauli_list)
276276

277277
for pauli_idx, pauli in enumerate(reversed(pauli_list)):
278-
n_qubits = pauli[1].numberofqubits
278+
n_qubits = pauli[1].num_qubits
279279
# changes bases if necessary
280280
nontrivial_pauli_indices = []
281281
for qubit_idx in range(n_qubits):

qiskit/aqua/operators/pauli_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# This code is part of Qiskit.
44
#
5-
# (C) Copyright IBM 2018, 2019.
5+
# (C) Copyright IBM 2018, 2020.
66
#
77
# This code is licensed under the Apache License, Version 2.0. You may
88
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -45,9 +45,9 @@ def _create_nodes(self, paulis):
4545
return tuple(pauli_operators), tuple(pauli_weights) # fix their ordering
4646

4747
def _get_nqbits(self):
48-
nqbits = self.nodes[0].numberofqubits
48+
nqbits = self.nodes[0].num_qubits
4949
for i in range(1, len(self.nodes)):
50-
assert nqbits == self.nodes[i].numberofqubits, "different number of qubits"
50+
assert nqbits == self.nodes[i].num_qubits, "different number of qubits"
5151
return nqbits
5252

5353
def _create_edges(self):

qiskit/aqua/operators/tpb_grouped_weighted_pauli_operator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# This code is part of Qiskit.
44
#
5-
# (C) Copyright IBM 2019.
5+
# (C) Copyright IBM 2019, 2020.
66
#
77
# This code is licensed under the Apache License, Version 2.0. You may
88
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -115,7 +115,7 @@ def unsorted_grouping(cls, weighted_pauli_operator):
115115
"""
116116
paulis = weighted_pauli_operator.paulis
117117
temp_paulis = copy.deepcopy(paulis)
118-
n = paulis[0][1].numberofqubits
118+
n = paulis[0][1].num_qubits
119119
grouped_paulis = []
120120
sorted_paulis = []
121121

qiskit/aqua/operators/weighted_pauli_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def num_qubits(self):
115115
int: number of qubits
116116
"""
117117
if not self.is_empty():
118-
return self._paulis[0][1].numberofqubits
118+
return self._paulis[0][1].num_qubits
119119
else:
120120
logger.warning("Operator is empty, Return 0.")
121121
return 0

0 commit comments

Comments
 (0)