Skip to content

Commit

Permalink
Rename expectation.py to result.py
Browse files Browse the repository at this point in the history
  • Loading branch information
chmwzc committed Apr 9, 2024
1 parent 814a4cc commit 78435b7
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/qibochem/measurement/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from qibochem.measurement.expectation import expectation
from qibochem.measurement.result import expectation
8 changes: 4 additions & 4 deletions src/qibochem/measurement/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def check_terms_commutativity(term1, term2, qubitwise=False):
"""
# Get a list of common qubits for each term
common_qubits = sorted(

Check warning on line 19 in src/qibochem/measurement/optimization.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/measurement/optimization.py#L19

Added line #L19 was not covered by tests
{_term[1] for _term in term1 if _term[0] != "I"} & {_term[1] for _term in term2 if _term[0] != "I"}
{_term[1:] for _term in term1 if _term[0] != "I"} & {_term[1:] for _term in term2 if _term[0] != "I"}
)
if not common_qubits:
return True

Check warning on line 23 in src/qibochem/measurement/optimization.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/measurement/optimization.py#L22-L23

Added lines #L22 - L23 were not covered by tests
# Get the single Pauli operators for the common qubits for both Pauli terms
term1_ops = [_op for _op in term1 if _op[1] in common_qubits]
term2_ops = [_op for _op in term2 if _op[1] in common_qubits]
term1_ops = [_op for _op in term1 if _op[1:] in common_qubits]
term2_ops = [_op for _op in term2 if _op[1:] in common_qubits]
if qubitwise:

Check warning on line 27 in src/qibochem/measurement/optimization.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/measurement/optimization.py#L25-L27

Added lines #L25 - L27 were not covered by tests
# Qubitwise: Compare the Pauli terms at the common qubits. Any difference => False
return all(_op1 == _op2 for _op1, _op2 in zip(term1_ops, term2_ops))

Check warning on line 29 in src/qibochem/measurement/optimization.py

View check run for this annotation

Codecov / codecov/patch

src/qibochem/measurement/optimization.py#L29

Added line #L29 was not covered by tests
Expand Down Expand Up @@ -61,7 +61,7 @@ def measurement_basis_rotations(hamiltonian, n_qubits, grouping=None):
if z_only_terms:
result.append(([gates.M(_i) for _i in range(n_qubits)], z_only_terms))
else:
result.append(([], []))
result.append(([], [])) # No terms with only Z's
# Then add the X/Y terms in
if xy_terms:
if grouping is None:
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions tests/test_basis_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from qibo import Circuit, gates, models

from qibochem.ansatz import basis_rotation
from qibochem.driver.molecule import Molecule
from qibochem.measurement.expectation import expectation

# from qibo.optimizers import optimize
from qibochem.driver import Molecule
from qibochem.measurement import expectation


def test_unitary():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hardware_efficient.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from qibochem.ansatz import he_circuit
from qibochem.driver import Molecule
from qibochem.measurement.expectation import expectation
from qibochem.measurement import expectation


def test_he_circuit():
Expand Down
6 changes: 3 additions & 3 deletions tests/test_hf_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import pytest

from qibochem.ansatz.hf_reference import hf_circuit
from qibochem.driver.molecule import Molecule
from qibochem.measurement.expectation import expectation
from qibochem.ansatz import hf_circuit
from qibochem.driver import Molecule
from qibochem.measurement import expectation


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from qibo.symbols import Z

from qibochem.driver import Molecule
from qibochem.measurement.expectation import expectation
from qibochem.measurement import expectation


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ucc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from qibo import Circuit, gates, symbols
from qibo.hamiltonians import SymbolicHamiltonian

from qibochem.ansatz.hf_reference import hf_circuit
from qibochem.ansatz import hf_circuit
from qibochem.ansatz.ucc import (
expi_pauli,
generate_excitations,
Expand Down

0 comments on commit 78435b7

Please sign in to comment.