Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(__init__.py): simplified funtion path #34

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/orquestra/vqa/algorithms/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .qaoa import QAOA
from .qcbm import QCBM
from .vqe import VQE
4 changes: 2 additions & 2 deletions src/orquestra/vqa/algorithms/qaoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from orquestra.quantum.operators import PauliRepresentation
from scipy.optimize import OptimizeResult

from orquestra.vqa.ansatz.qaoa_farhi import QAOAFarhiAnsatz
from orquestra.vqa.ansatz import QAOAFarhiAnsatz
from orquestra.vqa.api.ansatz import Ansatz
from orquestra.vqa.cost_function.cost_function import (
from orquestra.vqa.cost_function import (
create_cost_function,
substitution_based_estimation_tasks_factory,
)
Expand Down
2 changes: 1 addition & 1 deletion src/orquestra/vqa/algorithms/qcbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from scipy.optimize import OptimizeResult

from orquestra.vqa.ansatz.qcbm import QCBMAnsatz
from orquestra.vqa.ansatz import QCBMAnsatz
from orquestra.vqa.cost_function.qcbm_cost_function import create_QCBM_cost_function


Expand Down
2 changes: 1 addition & 1 deletion src/orquestra/vqa/algorithms/vqe.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from scipy.optimize import OptimizeResult

from orquestra.vqa.api.ansatz import Ansatz
from orquestra.vqa.cost_function.cost_function import (
from orquestra.vqa.cost_function import (
create_cost_function,
substitution_based_estimation_tasks_factory,
)
Expand Down
15 changes: 15 additions & 0 deletions src/orquestra/vqa/ansatz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from .kbody import XAnsatz, XZAnsatz
from .qaoa_farhi import (
QAOAFarhiAnsatz,
create_all_x_mixer_hamiltonian,
create_farhi_qaoa_circuits,
)
from .qaoa_warm_start import WarmStartQAOAAnsatz, convert_relaxed_solution_to_angles
from .qcbm._qcbm import (
QCBMAnsatz,
get_entangling_layer,
load_qcbm_ansatz_set,
save_qcbm_ansatz_set,
)
from .quantum_compiling import HEAQuantumCompilingAnsatz
from .singlet_uccsd import SingletUCCSDAnsatz
2 changes: 1 addition & 1 deletion src/orquestra/vqa/ansatz/qcbm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
################################################################################
# © Copyright 2022 Zapata Computing Inc.
################################################################################
from ._qcbm import QCBMAnsatz
# from ._qcbm import QCBMAnsatz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess delete this file?

10 changes: 10 additions & 0 deletions src/orquestra/vqa/cost_function/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .cost_function import (
add_normal_noise,
create_cost_function,
dynamic_circuit_estimation_tasks_factory,
expectation_value_estimation_tasks_factory,
fix_parameters,
substitution_based_estimation_tasks_factory,
sum_expectation_values,
)
from .qcbm_cost_function import create_QCBM_cost_function
6 changes: 6 additions & 0 deletions src/orquestra/vqa/estimation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .context_selection import (
get_context_selection_circuit_for_group,
perform_context_selection,
)
from .cvar import CvarEstimator
from .gibbs_objective import GibbsObjectiveEstimator
3 changes: 3 additions & 0 deletions src/orquestra/vqa/opt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .fourier_qaoa import FourierOptimizer, convert_u_v_to_gamma_beta
from .layerwise_ansatz_optimizer import LayerwiseAnsatzOptimizer, append_random_params
from .recursive_qaoa import RecursiveQAOA
1 change: 1 addition & 0 deletions src/orquestra/vqa/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .mock_objects import MockAnsatz
9 changes: 4 additions & 5 deletions tests/orquestra/vqa/algorithms/qaoa_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import pytest
from orquestra.opt.optimizers import ScipyOptimizer
from orquestra.quantum.operators import PauliTerm
from orquestra.quantum.runners.symbolic_simulator import SymbolicSimulator
from orquestra.quantum.runners import SymbolicSimulator

from orquestra.vqa.algorithms.qaoa import QAOA
from orquestra.vqa.ansatz.qaoa_farhi import QAOAFarhiAnsatz
from orquestra.vqa.ansatz.qaoa_warm_start import WarmStartQAOAAnsatz
from orquestra.vqa.estimation.cvar import CvarEstimator
from orquestra.vqa.algorithms import QAOA
from orquestra.vqa.ansatz import QAOAFarhiAnsatz, WarmStartQAOAAnsatz
from orquestra.vqa.estimation import CvarEstimator


@pytest.fixture()
Expand Down
8 changes: 4 additions & 4 deletions tests/orquestra/vqa/algorithms/qcbm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from orquestra.quantum.distributions.BAS_dataset import (
get_bars_and_stripes_target_distribution,
)
from orquestra.quantum.runners.symbolic_simulator import SymbolicSimulator
from orquestra.quantum.runners import SymbolicSimulator

from orquestra.vqa.algorithms.qcbm import QCBM
from orquestra.vqa.ansatz.qcbm import QCBMAnsatz
from orquestra.vqa.estimation.cvar import CvarEstimator
from orquestra.vqa.algorithms import QCBM
from orquestra.vqa.ansatz import QCBMAnsatz
from orquestra.vqa.estimation import CvarEstimator

N_LAYERS = 2
N_QUBITS = 4
Expand Down
8 changes: 4 additions & 4 deletions tests/orquestra/vqa/algorithms/vqe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from orquestra.opt.optimizers import ScipyOptimizer
from orquestra.quantum.api.estimation import EstimationPreprocessor
from orquestra.quantum.operators import PauliTerm
from orquestra.quantum.runners.symbolic_simulator import SymbolicSimulator
from orquestra.quantum.runners import SymbolicSimulator

from orquestra.vqa.algorithms.vqe import VQE
from orquestra.vqa.ansatz.quantum_compiling import HEAQuantumCompilingAnsatz
from orquestra.vqa.estimation.cvar import CvarEstimator
from orquestra.vqa.algorithms import VQE
from orquestra.vqa.ansatz import HEAQuantumCompilingAnsatz
from orquestra.vqa.estimation import CvarEstimator
from orquestra.vqa.grouping import group_greedily, group_individually
from orquestra.vqa.shot_allocation import (
allocate_shots_proportionally,
Expand Down
2 changes: 1 addition & 1 deletion tests/orquestra/vqa/ansatz/qaoa_farhi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from orquestra.quantum.operators import PauliSum, PauliTerm
from orquestra.quantum.utils import compare_unitary

from orquestra.vqa.ansatz.qaoa_farhi import (
from orquestra.vqa.ansatz import (
QAOAFarhiAnsatz,
create_all_x_mixer_hamiltonian,
create_farhi_qaoa_circuits,
Expand Down
4 changes: 2 additions & 2 deletions tests/orquestra/vqa/ansatz/qcbm/qcbm_ansatz_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import pytest
from orquestra.quantum.circuits import RX, RZ, XX, Circuit

from orquestra.vqa.ansatz.qcbm._qcbm import (
from orquestra.vqa.ansatz import (
QCBMAnsatz,
get_entangling_layer,
load_qcbm_ansatz_set,
save_qcbm_ansatz_set,
)
from orquestra.vqa.ansatz.qcbm._qcbm_utils import get_entangling_layer
from orquestra.vqa.api.ansatz_test import AnsatzTests


Expand Down
2 changes: 1 addition & 1 deletion tests/orquestra/vqa/ansatz/quantum_compiling_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
import pytest

from orquestra.vqa.ansatz.quantum_compiling import HEAQuantumCompilingAnsatz
from orquestra.vqa.ansatz import HEAQuantumCompilingAnsatz
from orquestra.vqa.api.ansatz_test import AnsatzTests


Expand Down
4 changes: 2 additions & 2 deletions tests/orquestra/vqa/cost_function/cost_function_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
import pytest
from orquestra.quantum.estimation._estimation import (
from orquestra.quantum.estimation import (
calculate_exact_expectation_values,
estimate_expectation_values_by_averaging,
)
Expand All @@ -15,7 +15,7 @@
from orquestra.quantum.runners import SymbolicSimulator
from sympy import Symbol

from orquestra.vqa.cost_function.cost_function import (
from orquestra.vqa.cost_function import (
add_normal_noise,
create_cost_function,
dynamic_circuit_estimation_tasks_factory,
Expand Down
6 changes: 3 additions & 3 deletions tests/orquestra/vqa/opt/fourier_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from orquestra.opt.api.optimizer import optimization_result
from orquestra.opt.api.optimizer_test import NESTED_OPTIMIZER_CONTRACTS
from orquestra.opt.mock_objects import MockOptimizer, mock_cost_function
from orquestra.quantum.estimation._estimation import calculate_exact_expectation_values
from orquestra.quantum.estimation import calculate_exact_expectation_values
from orquestra.quantum.operators import PauliTerm
from orquestra.quantum.runners import SymbolicSimulator

from orquestra.vqa.ansatz.qaoa_farhi import QAOAFarhiAnsatz
from orquestra.vqa.ansatz import QAOAFarhiAnsatz
from orquestra.vqa.api.ansatz import Ansatz
from orquestra.vqa.cost_function.cost_function import (
from orquestra.vqa.cost_function import (
create_cost_function,
substitution_based_estimation_tasks_factory,
)
Expand Down
8 changes: 3 additions & 5 deletions tests/orquestra/vqa/opt/recursive_qaoa_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
from orquestra.opt.api.optimizer_test import NESTED_OPTIMIZER_CONTRACTS
from orquestra.opt.mock_objects import MockOptimizer
from orquestra.quantum.api.estimation import EstimationTask
from orquestra.quantum.estimation._estimation import (
estimate_expectation_values_by_averaging,
)
from orquestra.quantum.estimation import estimate_expectation_values_by_averaging
from orquestra.quantum.operators import PauliRepresentation, PauliTerm
from orquestra.quantum.runners import SymbolicSimulator

from orquestra.vqa.ansatz.qaoa_farhi import QAOAFarhiAnsatz
from orquestra.vqa.ansatz import QAOAFarhiAnsatz
from orquestra.vqa.api.ansatz import Ansatz
from orquestra.vqa.cost_function.cost_function import (
from orquestra.vqa.cost_function import (
create_cost_function,
substitution_based_estimation_tasks_factory,
)
Expand Down