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

Commit 48e7149

Browse files
authored
Merge pull request #59 from chunfuchen/fix/bug_in_operator
resolve #58
2 parents 2379b6a + 9bb320c commit 48e7149

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

qiskit_aqua/operator.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -764,18 +764,18 @@ def eval(self, operator_mode, input_circuit, backend, execute_config={}, qjob_co
764764

765765
# If the statevector is already a vector, skip the evaluation from quantum simulator.
766766

767-
if backend.startswith('local'):
768-
self.MAX_CIRCUITS_PER_JOB = sys.maxsize
769-
770767
if isinstance(input_circuit, np.ndarray):
771768
avg = self._eval_directly(input_circuit)
772769
std_dev = 0.0
773-
elif "statevector" in backend:
774-
execute_config['shots'] = 1
775-
avg = self._eval_with_statevector(operator_mode, input_circuit, backend, execute_config)
776-
std_dev = 0.0
777770
else:
778-
avg, std_dev = self._eval_multiple_shots(operator_mode, input_circuit, backend, execute_config, qjob_config)
771+
if backend.startswith('local'):
772+
self.MAX_CIRCUITS_PER_JOB = sys.maxsize
773+
if "statevector" in backend:
774+
execute_config['shots'] = 1
775+
avg = self._eval_with_statevector(operator_mode, input_circuit, backend, execute_config)
776+
std_dev = 0.0
777+
else:
778+
avg, std_dev = self._eval_multiple_shots(operator_mode, input_circuit, backend, execute_config, qjob_config)
779779
return avg, std_dev
780780

781781
def convert(self, input_format, output_format, force=False):
@@ -1498,14 +1498,14 @@ def kernel_F2(matrix_in):
14981498
def find_Z2_symmetries(self):
14991499
"""
15001500
Finds Z2 Pauli-type symmetries of an Operator
1501-
1501+
15021502
Returns:
1503-
[Pauli]: the list of Pauli objects representing the Z2 symmetries
1503+
[Pauli]: the list of Pauli objects representing the Z2 symmetries
15041504
[Pauli]: the list of single - qubit Pauli objects to construct the Cliffors operators
15051505
[Operators]: the list of Clifford unitaries to block diagonalize Operator
15061506
[int]: the list of support of the single-qubit Pauli objects used to build the clifford operators
15071507
"""
1508-
1508+
15091509
Pauli_symmetries = []
15101510
sq_paulis = []
15111511
cliffords = []
@@ -1539,7 +1539,7 @@ def find_Z2_symmetries(self):
15391539
stacked_symmetries[row, col + symm_shape[1] // 2] == 0) or
15401540
(stacked_symmetries[row, col] == 1 and
15411541
stacked_symmetries[row, col + symm_shape[1] // 2] == 1)):
1542-
sq_paulis.append(Pauli(np.zeros(symm_shape[1] // 2),
1542+
sq_paulis.append(Pauli(np.zeros(symm_shape[1] // 2),
15431543
np.zeros(symm_shape[1] // 2)))
15441544
sq_paulis[row].v[col] = 0
15451545
sq_paulis[row].w[col] = 1
@@ -1563,18 +1563,18 @@ def find_Z2_symmetries(self):
15631563
sq_list.append(col)
15641564
break
15651565

1566-
# case symmetries other than one at (row) have Y or I on col qubit
1567-
Y_or_I = True
1566+
# case symmetries other than one at (row) have Y or I on col qubit
1567+
Y_or_I = True
15681568
for symm_idx in range(symm_shape[0] - 1):
15691569
if not ( (stacked_symm_del[symm_idx, col] == 1 and
15701570
stacked_symm_del[symm_idx, col + symm_shape[1] // 2] == 1)
15711571
or (stacked_symm_del[symm_idx, col] == 0 and
15721572
stacked_symm_del[symm_idx, col + symm_shape[1] // 2] == 0) ):
15731573
Y_or_I = False
15741574
if Y_or_I == True:
1575-
if ( (stacked_symmetries[row, col] == 0 and
1575+
if ( (stacked_symmetries[row, col] == 0 and
15761576
stacked_symmetries[row, col + symm_shape[1] // 2] == 1) or
1577-
(stacked_symmetries[row, col] == 1 and
1577+
(stacked_symmetries[row, col] == 1 and
15781578
stacked_symmetries[row, col + symm_shape[1] // 2] == 0) ):
15791579
sq_paulis.append(Pauli(np.zeros(symm_shape[1] // 2), np.zeros(symm_shape[1] // 2)))
15801580
sq_paulis[row].v[col] = 1
@@ -1590,9 +1590,9 @@ def find_Z2_symmetries(self):
15901590
@staticmethod
15911591
def qubit_tapering(operator, cliffords, sq_list, tapering_values):
15921592
"""
1593-
Builds an Operator which has a number of qubits tapered off,
1593+
Builds an Operator which has a number of qubits tapered off,
15941594
based on a block-diagonal Operator built using a list of cliffords.
1595-
The block-diagonal subspace is an input parameter, set through the list
1595+
The block-diagonal subspace is an input parameter, set through the list
15961596
tapering_values, which takes values +/- 1.
15971597
15981598
Args:
@@ -1615,11 +1615,11 @@ def qubit_tapering(operator, cliffords, sq_list, tapering_values):
16151615
qubit list and tapering values')
16161616

16171617
for clifford in cliffords:
1618-
operator = clifford * operator * clifford
1618+
operator = clifford * operator * clifford
16191619

16201620
operator_out = Operator(paulis=[])
16211621
n = len(operator.paulis[0][1].v)
1622-
for pauli_term in operator.paulis:
1622+
for pauli_term in operator.paulis:
16231623
coeff_out = pauli_term[0]
16241624
for qubit_idx, qubit in enumerate(sq_list):
16251625
if not (pauli_term[1].v[qubit] == 0 and pauli_term[1].w[qubit] == 0):
@@ -1633,7 +1633,7 @@ def qubit_tapering(operator, cliffords, sq_list, tapering_values):
16331633
pauli_term_out = [coeff_out, Pauli(np.array(v_temp), np.array(w_temp))]
16341634
operator_out += Operator(paulis=[pauli_term_out])
16351635

1636-
return operator_out
1636+
return operator_out
16371637

16381638
def zeros_coeff_elimination(self):
16391639
"""

0 commit comments

Comments
 (0)