Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
Fix Pauli.numberofqubits deprecation (#881)
Browse files Browse the repository at this point in the history
* Fix Pauli.numberofqubits deprecation
  • Loading branch information
manoelmarques authored Apr 1, 2020
1 parent 3b025d8 commit e031d28
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions qiskit/aqua/operators/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

for pauli_idx, pauli in enumerate(reversed(pauli_list)):
n_qubits = pauli[1].numberofqubits
n_qubits = pauli[1].num_qubits
# changes bases if necessary
nontrivial_pauli_indices = []
for qubit_idx in range(n_qubits):
Expand Down
6 changes: 3 additions & 3 deletions qiskit/aqua/operators/pauli_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

def _get_nqbits(self):
nqbits = self.nodes[0].numberofqubits
nqbits = self.nodes[0].num_qubits
for i in range(1, len(self.nodes)):
assert nqbits == self.nodes[i].numberofqubits, "different number of qubits"
assert nqbits == self.nodes[i].num_qubits, "different number of qubits"
return nqbits

def _create_edges(self):
Expand Down
4 changes: 2 additions & 2 deletions qiskit/aqua/operators/tpb_grouped_weighted_pauli_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This code is part of Qiskit.
#
# (C) Copyright IBM 2019.
# (C) Copyright IBM 2019, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -115,7 +115,7 @@ def unsorted_grouping(cls, weighted_pauli_operator):
"""
paulis = weighted_pauli_operator.paulis
temp_paulis = copy.deepcopy(paulis)
n = paulis[0][1].numberofqubits
n = paulis[0][1].num_qubits
grouped_paulis = []
sorted_paulis = []

Expand Down
2 changes: 1 addition & 1 deletion qiskit/aqua/operators/weighted_pauli_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def num_qubits(self):
int: number of qubits
"""
if not self.is_empty():
return self._paulis[0][1].numberofqubits
return self._paulis[0][1].num_qubits
else:
logger.warning("Operator is empty, Return 0.")
return 0
Expand Down

0 comments on commit e031d28

Please sign in to comment.