From 7f4119a28a7f2261f793ad8a3655ecc2e1d32b0a Mon Sep 17 00:00:00 2001 From: Fionn Malone Date: Mon, 29 Jul 2024 17:25:21 -0700 Subject: [PATCH] Move third_party to recirq/third_party (#361) * Move third_party to recirq --- .github/workflows/pythonpackage.yml | 1 - README.md | 6 ------ docs/qcqmc/experimental_wavefunctions.ipynb | 2 +- docs/qcqmc/full_workflow.ipynb | 7 +++---- docs/qcqmc/high_level.ipynb | 2 +- recirq/qcqmc/blueprint.py | 2 +- recirq/qcqmc/blueprint_test.py | 2 +- recirq/qcqmc/shadow_tomography_test.py | 2 +- recirq/third_party/__init__.py | 13 ++++++++++++ .../third_party}/quaff/LICENSE | 0 .../third_party}/quaff/README.md | 0 .../third_party}/quaff/__init__.py | 6 +++--- .../third_party}/quaff/basis_change.py | 2 +- .../third_party}/quaff/basis_change_test.py | 2 +- .../third_party}/quaff/comb.py | 0 .../third_party}/quaff/comb_test.py | 2 +- .../third_party}/quaff/cz_layer.py | 2 +- .../third_party}/quaff/cz_layer_test.py | 2 +- recirq/third_party/quaff/gates/__init__.py | 10 ++++++++++ .../third_party}/quaff/gates/fhf.py | 6 +++--- .../third_party}/quaff/gates/fhf_test.py | 2 +- .../third_party}/quaff/gates/foo.py | 0 .../third_party}/quaff/gates/hadamard_free.py | 2 +- .../quaff/gates/hadamard_free_test.py | 2 +- .../third_party}/quaff/gates/parameterized.py | 4 ++-- .../quaff/gates/parameterized_test.py | 2 +- .../quaff/gates/single_qubit_layer.py | 0 .../quaff/gates/single_qubit_layer_test.py | 2 +- .../quaff/gates/truncated_clifford.py | 10 +++++----- .../quaff/gates/truncated_clifford_test.py | 2 +- .../third_party}/quaff/indexing.py | 0 .../third_party}/quaff/indexing_test.py | 2 +- .../third_party}/quaff/json_resolver.py | 4 +++- .../third_party}/quaff/json_serialization.py | 0 .../third_party}/quaff/linalg.py | 2 +- .../third_party}/quaff/linalg_test.py | 2 +- .../third_party}/quaff/random.py | 2 +- .../third_party}/quaff/random_test.py | 2 +- .../third_party}/quaff/sampling/__init__.py | 2 +- .../quaff/sampling/boolean_sampler.py | 4 ++-- .../quaff/sampling/clifford_sampler.py | 4 ++-- .../sampling/invertible_matrix_sampler.py | 4 ++-- .../third_party}/quaff/sampling/sampler.py | 0 .../third_party}/quaff/sampling/testing.py | 4 ++-- .../third_party}/quaff/testing.py | 2 +- setup.py | 2 ++ third_party/quaff/quaff/gates/__init__.py | 10 ---------- third_party/quaff/requirements.txt | 3 --- third_party/quaff/setup.py | 20 ------------------- 49 files changed, 75 insertions(+), 89 deletions(-) create mode 100644 recirq/third_party/__init__.py rename {third_party => recirq/third_party}/quaff/LICENSE (100%) rename {third_party => recirq/third_party}/quaff/README.md (100%) rename {third_party/quaff => recirq/third_party}/quaff/__init__.py (87%) rename {third_party/quaff => recirq/third_party}/quaff/basis_change.py (99%) rename {third_party/quaff => recirq/third_party}/quaff/basis_change_test.py (99%) rename {third_party/quaff => recirq/third_party}/quaff/comb.py (100%) rename {third_party/quaff => recirq/third_party}/quaff/comb_test.py (97%) rename {third_party/quaff => recirq/third_party}/quaff/cz_layer.py (98%) rename {third_party/quaff => recirq/third_party}/quaff/cz_layer_test.py (99%) create mode 100644 recirq/third_party/quaff/gates/__init__.py rename {third_party/quaff => recirq/third_party}/quaff/gates/fhf.py (97%) rename {third_party/quaff => recirq/third_party}/quaff/gates/fhf_test.py (98%) rename {third_party/quaff => recirq/third_party}/quaff/gates/foo.py (100%) rename {third_party/quaff => recirq/third_party}/quaff/gates/hadamard_free.py (99%) rename {third_party/quaff => recirq/third_party}/quaff/gates/hadamard_free_test.py (98%) rename {third_party/quaff => recirq/third_party}/quaff/gates/parameterized.py (93%) rename {third_party/quaff => recirq/third_party}/quaff/gates/parameterized_test.py (98%) rename {third_party/quaff => recirq/third_party}/quaff/gates/single_qubit_layer.py (100%) rename {third_party/quaff => recirq/third_party}/quaff/gates/single_qubit_layer_test.py (96%) rename {third_party/quaff => recirq/third_party}/quaff/gates/truncated_clifford.py (94%) rename {third_party/quaff => recirq/third_party}/quaff/gates/truncated_clifford_test.py (98%) rename {third_party/quaff => recirq/third_party}/quaff/indexing.py (100%) rename {third_party/quaff => recirq/third_party}/quaff/indexing_test.py (98%) rename {third_party/quaff => recirq/third_party}/quaff/json_resolver.py (77%) rename {third_party/quaff => recirq/third_party}/quaff/json_serialization.py (100%) rename {third_party/quaff => recirq/third_party}/quaff/linalg.py (99%) rename {third_party/quaff => recirq/third_party}/quaff/linalg_test.py (99%) rename {third_party/quaff => recirq/third_party}/quaff/random.py (97%) rename {third_party/quaff => recirq/third_party}/quaff/random_test.py (96%) rename {third_party/quaff => recirq/third_party}/quaff/sampling/__init__.py (84%) rename {third_party/quaff => recirq/third_party}/quaff/sampling/boolean_sampler.py (89%) rename {third_party/quaff => recirq/third_party}/quaff/sampling/clifford_sampler.py (98%) rename {third_party/quaff => recirq/third_party}/quaff/sampling/invertible_matrix_sampler.py (97%) rename {third_party/quaff => recirq/third_party}/quaff/sampling/sampler.py (100%) rename {third_party/quaff => recirq/third_party}/quaff/sampling/testing.py (92%) rename {third_party/quaff => recirq/third_party}/quaff/testing.py (97%) delete mode 100644 third_party/quaff/quaff/gates/__init__.py delete mode 100644 third_party/quaff/requirements.txt delete mode 100644 third_party/quaff/setup.py diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 1b477cf8..70032224 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -40,7 +40,6 @@ jobs: python -m pip install --upgrade pip python dev_tools/write-ci-requirements.py --relative-cirq-version=${{ matrix.cirq-version }} --all-extras pip install -r ci-requirements.txt - pip install -e third_party/quaff pip install --no-deps -e . - name: Lint with flake8 diff --git a/README.md b/README.md index 557aadbd..bec1fc13 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,6 @@ install from source: Documentation is available at https://quantumai.google/cirq/experiments. -To run code relevant for the [QCQMC experiment](https://www.nature.com/articles/s41586-021-04351-z) -you must also install `quaff` which is vendored with recirq. From the top level of -the recirq repository do: - - pip install third_party/quaff - ## See Also This code leverages [Cirq](https://github.com/quantumlib/Cirq) as a diff --git a/docs/qcqmc/experimental_wavefunctions.ipynb b/docs/qcqmc/experimental_wavefunctions.ipynb index 7ecd171c..6911b8e4 100644 --- a/docs/qcqmc/experimental_wavefunctions.ipynb +++ b/docs/qcqmc/experimental_wavefunctions.ipynb @@ -86,7 +86,7 @@ "| 8896 | -1.954930 | -1.947458 | -1.913889 | -1.913068 |\n", "| 15000 | -1.954356 | -1.948894 | -1.913894 | -1.913082 |\n", "\n", - "Each column represents an independented partitioned shadow tomography experiment.\n" + "Each column represents an independent partitioned shadow tomography experiment.\n" ] }, { diff --git a/docs/qcqmc/full_workflow.ipynb b/docs/qcqmc/full_workflow.ipynb index 34ea08fe..fd3e9c0f 100644 --- a/docs/qcqmc/full_workflow.ipynb +++ b/docs/qcqmc/full_workflow.ipynb @@ -209,8 +209,7 @@ ")\n", "print(f\"Reconstructed shadow wavefunction energy: {ipie_data.variational_energy}\")\n", "print(f\"Ideal trial wavefunction energy: {trial_wf.ansatz_energy}\")\n", - "print(f\"FCI energy: {trial_wf.fci_energy}\")\n", - "print(ipie_data)" + "print(f\"FCI energy: {trial_wf.fci_energy}\")" ] }, { @@ -372,9 +371,9 @@ "source": [ "# Next steps\n", "\n", - "The results presented above are far worse than reported in the paper. In practice one needs to:\n", + "The results presented above are worse than reported in the paper. In practice one needs to:\n", "\n", - "1. Optimize the trial wavefunction parameters\n", + "1. Carefully converge the trial wavefunction parameters by scanning over multiple random restarts.\n", "2. Converge the reconstructed shadow wavefunction with respect to: `n_cliffords`\n", "3. The AFQMC part of the simulations can be sped up using MPI parallelism. See [ipie](https://github.com/JoonhoLee-Group/ipie) for more information. The number of walkers should also be increased to obtain better statistics and reduce any population control biases. The number of samples (`num_blocks`) should also be increased (`ETotal_nsamp_ac` should be about 100 for statistically significant results.) " ] diff --git a/docs/qcqmc/high_level.ipynb b/docs/qcqmc/high_level.ipynb index 39e1154b..281facbc 100644 --- a/docs/qcqmc/high_level.ipynb +++ b/docs/qcqmc/high_level.ipynb @@ -301,7 +301,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.10.10" } }, "nbformat": 4, diff --git a/recirq/qcqmc/blueprint.py b/recirq/qcqmc/blueprint.py index 2ab2779e..7f771da3 100644 --- a/recirq/qcqmc/blueprint.py +++ b/recirq/qcqmc/blueprint.py @@ -17,7 +17,7 @@ import attrs import cirq import numpy as np -import quaff +from recirq.third_party import quaff from recirq.qcqmc import config, data, for_refactor, trial_wf diff --git a/recirq/qcqmc/blueprint_test.py b/recirq/qcqmc/blueprint_test.py index dad322b3..b973b4ed 100644 --- a/recirq/qcqmc/blueprint_test.py +++ b/recirq/qcqmc/blueprint_test.py @@ -16,7 +16,7 @@ import cirq import numpy as np import pytest -import quaff +from recirq.third_party import quaff from recirq.qcqmc.blueprint import (BlueprintData, BlueprintParamsTrialWf, _get_truncated_cliffords) diff --git a/recirq/qcqmc/shadow_tomography_test.py b/recirq/qcqmc/shadow_tomography_test.py index 1db41ba1..12cfcf8d 100644 --- a/recirq/qcqmc/shadow_tomography_test.py +++ b/recirq/qcqmc/shadow_tomography_test.py @@ -14,7 +14,7 @@ import cirq import numpy as np -import quaff +from recirq.third_party import quaff from recirq.qcqmc.bitstrings import get_bitstrings_a_b from recirq.qcqmc.shadow_tomography import ( diff --git a/recirq/third_party/__init__.py b/recirq/third_party/__init__.py new file mode 100644 index 00000000..0f6532ad --- /dev/null +++ b/recirq/third_party/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Google +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/third_party/quaff/LICENSE b/recirq/third_party/quaff/LICENSE similarity index 100% rename from third_party/quaff/LICENSE rename to recirq/third_party/quaff/LICENSE diff --git a/third_party/quaff/README.md b/recirq/third_party/quaff/README.md similarity index 100% rename from third_party/quaff/README.md rename to recirq/third_party/quaff/README.md diff --git a/third_party/quaff/quaff/__init__.py b/recirq/third_party/quaff/__init__.py similarity index 87% rename from third_party/quaff/quaff/__init__.py rename to recirq/third_party/quaff/__init__.py index 7478a7b7..02a7b693 100644 --- a/third_party/quaff/quaff/__init__.py +++ b/recirq/third_party/quaff/__init__.py @@ -1,4 +1,4 @@ -from quaff import indexing, json_serialization, linalg, random, testing +from recirq.third_party.quaff import indexing, json_serialization, linalg, random, testing from .basis_change import BasisChangeGate, get_clearing_network, get_reversal_network from .comb import binom, get_inversion_number, get_num_perms_with_inversion_number @@ -66,8 +66,8 @@ def _register_resolver() -> None: - from quaff.json_resolver import json_resolver - from quaff.json_serialization import _internal_register_resolver + from recirq.third_party.quaff.json_resolver import json_resolver + from recirq.third_party.quaff.json_serialization import _internal_register_resolver _internal_register_resolver(json_resolver) diff --git a/third_party/quaff/quaff/basis_change.py b/recirq/third_party/quaff/basis_change.py similarity index 99% rename from third_party/quaff/quaff/basis_change.py rename to recirq/third_party/quaff/basis_change.py index 000f9596..e461ebb7 100644 --- a/third_party/quaff/quaff/basis_change.py +++ b/recirq/third_party/quaff/basis_change.py @@ -2,7 +2,7 @@ import cirq import numpy as np -from quaff import indexing, linalg, random +from recirq.third_party.quaff import indexing, linalg, random class BasisChangeGate(cirq.Gate): diff --git a/third_party/quaff/quaff/basis_change_test.py b/recirq/third_party/quaff/basis_change_test.py similarity index 99% rename from third_party/quaff/quaff/basis_change_test.py rename to recirq/third_party/quaff/basis_change_test.py index 6b706771..9026a599 100644 --- a/third_party/quaff/quaff/basis_change_test.py +++ b/recirq/third_party/quaff/basis_change_test.py @@ -1,7 +1,7 @@ import cirq import numpy as np import pytest -import quaff +from recirq.third_party import quaff @pytest.mark.parametrize( diff --git a/third_party/quaff/quaff/comb.py b/recirq/third_party/quaff/comb.py similarity index 100% rename from third_party/quaff/quaff/comb.py rename to recirq/third_party/quaff/comb.py diff --git a/third_party/quaff/quaff/comb_test.py b/recirq/third_party/quaff/comb_test.py similarity index 97% rename from third_party/quaff/quaff/comb_test.py rename to recirq/third_party/quaff/comb_test.py index c43a6008..0533bf91 100644 --- a/third_party/quaff/quaff/comb_test.py +++ b/recirq/third_party/quaff/comb_test.py @@ -4,7 +4,7 @@ import numpy as np import pytest -import quaff +from recirq.third_party import quaff def test_get_num_perms_with_inversion_number(): diff --git a/third_party/quaff/quaff/cz_layer.py b/recirq/third_party/quaff/cz_layer.py similarity index 98% rename from third_party/quaff/quaff/cz_layer.py rename to recirq/third_party/quaff/cz_layer.py index 1c97b81c..b61e5ab7 100644 --- a/third_party/quaff/quaff/cz_layer.py +++ b/recirq/third_party/quaff/cz_layer.py @@ -4,7 +4,7 @@ import cirq import numpy as np -from quaff import basis_change, gates, indexing, linalg +from recirq.third_party.quaff import basis_change, gates, indexing, linalg def get_index_range(num_qubits: int, num_steps: int, i: int): diff --git a/third_party/quaff/quaff/cz_layer_test.py b/recirq/third_party/quaff/cz_layer_test.py similarity index 99% rename from third_party/quaff/quaff/cz_layer_test.py rename to recirq/third_party/quaff/cz_layer_test.py index 56c4ffda..193e633e 100644 --- a/third_party/quaff/quaff/cz_layer_test.py +++ b/recirq/third_party/quaff/cz_layer_test.py @@ -3,7 +3,7 @@ import cirq import numpy as np import pytest -import quaff +from recirq.third_party import quaff @pytest.mark.parametrize( diff --git a/recirq/third_party/quaff/gates/__init__.py b/recirq/third_party/quaff/gates/__init__.py new file mode 100644 index 00000000..a3c4ec7b --- /dev/null +++ b/recirq/third_party/quaff/gates/__init__.py @@ -0,0 +1,10 @@ +from recirq.third_party.quaff.gates.fhf import FHFGate +from recirq.third_party.quaff.gates.hadamard_free import HadamardFreeGate +from recirq.third_party.quaff.gates.parameterized import ( + get_parameterized_truncated_clifford_ops, + get_parameterized_truncated_cliffords_ops, + get_truncated_clifford_resolver, + get_truncated_cliffords_resolver, +) +from recirq.third_party.quaff.gates.single_qubit_layer import SingleQubitLayerGate +from recirq.third_party.quaff.gates.truncated_clifford import TruncatedCliffordGate diff --git a/third_party/quaff/quaff/gates/fhf.py b/recirq/third_party/quaff/gates/fhf.py similarity index 97% rename from third_party/quaff/quaff/gates/fhf.py rename to recirq/third_party/quaff/gates/fhf.py index 8b1121ea..f61c30cf 100644 --- a/third_party/quaff/quaff/gates/fhf.py +++ b/recirq/third_party/quaff/gates/fhf.py @@ -5,9 +5,9 @@ import cirq import numpy as np -from quaff import linalg, sampling, testing -from quaff.gates.hadamard_free import HadamardFreeGate -from quaff.gates.single_qubit_layer import SingleQubitLayerGate +from recirq.third_party.quaff import linalg, sampling, testing +from recirq.third_party.quaff.gates.hadamard_free import HadamardFreeGate +from recirq.third_party.quaff.gates.single_qubit_layer import SingleQubitLayerGate def _recover_permutation(matrix: np.ndarray) -> Optional[np.ndarray]: diff --git a/third_party/quaff/quaff/gates/fhf_test.py b/recirq/third_party/quaff/gates/fhf_test.py similarity index 98% rename from third_party/quaff/quaff/gates/fhf_test.py rename to recirq/third_party/quaff/gates/fhf_test.py index 0f7e47d6..8fe8466f 100644 --- a/third_party/quaff/quaff/gates/fhf_test.py +++ b/recirq/third_party/quaff/gates/fhf_test.py @@ -3,7 +3,7 @@ import cirq import numpy as np import pytest -import quaff +from recirq.third_party import quaff @pytest.mark.parametrize("n, seed", ((n, quaff.random_seed()) for n in range(1, 7))) diff --git a/third_party/quaff/quaff/gates/foo.py b/recirq/third_party/quaff/gates/foo.py similarity index 100% rename from third_party/quaff/quaff/gates/foo.py rename to recirq/third_party/quaff/gates/foo.py diff --git a/third_party/quaff/quaff/gates/hadamard_free.py b/recirq/third_party/quaff/gates/hadamard_free.py similarity index 99% rename from third_party/quaff/quaff/gates/hadamard_free.py rename to recirq/third_party/quaff/gates/hadamard_free.py index 1d27b0bc..fd990a41 100644 --- a/third_party/quaff/quaff/gates/hadamard_free.py +++ b/recirq/third_party/quaff/gates/hadamard_free.py @@ -4,7 +4,7 @@ import cirq import numpy as np -from quaff import indexing, linalg, random, testing +from recirq.third_party.quaff import indexing, linalg, random, testing @dataclass diff --git a/third_party/quaff/quaff/gates/hadamard_free_test.py b/recirq/third_party/quaff/gates/hadamard_free_test.py similarity index 98% rename from third_party/quaff/quaff/gates/hadamard_free_test.py rename to recirq/third_party/quaff/gates/hadamard_free_test.py index 0ffb98b8..8c3d6e37 100644 --- a/third_party/quaff/quaff/gates/hadamard_free_test.py +++ b/recirq/third_party/quaff/gates/hadamard_free_test.py @@ -3,7 +3,7 @@ import cirq import numpy as np import pytest -import quaff +from recirq.third_party import quaff def assert_hadamard_free_gate_unitary_is_good(n, gate): diff --git a/third_party/quaff/quaff/gates/parameterized.py b/recirq/third_party/quaff/gates/parameterized.py similarity index 93% rename from third_party/quaff/quaff/gates/parameterized.py rename to recirq/third_party/quaff/gates/parameterized.py index 3a8eb29e..fb4c81ed 100644 --- a/third_party/quaff/quaff/gates/parameterized.py +++ b/recirq/third_party/quaff/gates/parameterized.py @@ -2,8 +2,8 @@ import cirq import sympy -from quaff import cz_layer -from quaff.gates.truncated_clifford import TruncatedCliffordGate +from recirq.third_party.quaff import cz_layer +from recirq.third_party.quaff.gates.truncated_clifford import TruncatedCliffordGate def get_truncated_clifford_resolver( diff --git a/third_party/quaff/quaff/gates/parameterized_test.py b/recirq/third_party/quaff/gates/parameterized_test.py similarity index 98% rename from third_party/quaff/quaff/gates/parameterized_test.py rename to recirq/third_party/quaff/gates/parameterized_test.py index 1a19b5fc..104ebc9f 100644 --- a/third_party/quaff/quaff/gates/parameterized_test.py +++ b/recirq/third_party/quaff/gates/parameterized_test.py @@ -3,7 +3,7 @@ import cirq import numpy as np import pytest -import quaff +from recirq.third_party import quaff @pytest.mark.parametrize("n, seed", ((n, quaff.random_seed()) for n in range(1, 6))) diff --git a/third_party/quaff/quaff/gates/single_qubit_layer.py b/recirq/third_party/quaff/gates/single_qubit_layer.py similarity index 100% rename from third_party/quaff/quaff/gates/single_qubit_layer.py rename to recirq/third_party/quaff/gates/single_qubit_layer.py diff --git a/third_party/quaff/quaff/gates/single_qubit_layer_test.py b/recirq/third_party/quaff/gates/single_qubit_layer_test.py similarity index 96% rename from third_party/quaff/quaff/gates/single_qubit_layer_test.py rename to recirq/third_party/quaff/gates/single_qubit_layer_test.py index d3d4d45f..5ec903dd 100644 --- a/third_party/quaff/quaff/gates/single_qubit_layer_test.py +++ b/recirq/third_party/quaff/gates/single_qubit_layer_test.py @@ -1,7 +1,7 @@ import cirq import numpy as np import pytest -import quaff +from recirq.third_party import quaff def test_single_qubit_layer_gate_bad(): diff --git a/third_party/quaff/quaff/gates/truncated_clifford.py b/recirq/third_party/quaff/gates/truncated_clifford.py similarity index 94% rename from third_party/quaff/quaff/gates/truncated_clifford.py rename to recirq/third_party/quaff/gates/truncated_clifford.py index d81e5fe2..3f6bb1d4 100644 --- a/third_party/quaff/quaff/gates/truncated_clifford.py +++ b/recirq/third_party/quaff/gates/truncated_clifford.py @@ -4,11 +4,11 @@ import cirq import numpy as np -from quaff import comb, cz_layer, indexing, linalg, sampling, testing -from quaff.gates.fhf import FHFGate -from quaff.gates.hadamard_free import HadamardFreeGate -from quaff.gates.single_qubit_layer import SingleQubitLayerGate -from quaff.linalg import BooleanMatrix, BooleanVector +from recirq.third_party.quaff import comb, cz_layer, indexing, linalg, sampling, testing +from recirq.third_party.quaff.gates.fhf import FHFGate +from recirq.third_party.quaff.gates.hadamard_free import HadamardFreeGate +from recirq.third_party.quaff.gates.single_qubit_layer import SingleQubitLayerGate +from recirq.third_party.quaff.linalg import BooleanMatrix, BooleanVector @dataclass(eq=True, order=True) diff --git a/third_party/quaff/quaff/gates/truncated_clifford_test.py b/recirq/third_party/quaff/gates/truncated_clifford_test.py similarity index 98% rename from third_party/quaff/quaff/gates/truncated_clifford_test.py rename to recirq/third_party/quaff/gates/truncated_clifford_test.py index 62da5664..d6838e02 100644 --- a/third_party/quaff/quaff/gates/truncated_clifford_test.py +++ b/recirq/third_party/quaff/gates/truncated_clifford_test.py @@ -1,7 +1,7 @@ import cirq import numpy as np import pytest -from quaff import ( +from recirq.third_party.quaff import ( DEFAULT_RESOLVERS, HadamardFreeGate, TruncatedCliffordGate, diff --git a/third_party/quaff/quaff/indexing.py b/recirq/third_party/quaff/indexing.py similarity index 100% rename from third_party/quaff/quaff/indexing.py rename to recirq/third_party/quaff/indexing.py diff --git a/third_party/quaff/quaff/indexing_test.py b/recirq/third_party/quaff/indexing_test.py similarity index 98% rename from third_party/quaff/quaff/indexing_test.py rename to recirq/third_party/quaff/indexing_test.py index 56da6c08..5ddaf802 100644 --- a/third_party/quaff/quaff/indexing_test.py +++ b/recirq/third_party/quaff/indexing_test.py @@ -2,7 +2,7 @@ import numpy as np import pytest -import quaff +from recirq.third_party import quaff @pytest.mark.parametrize("n, big_endian", itertools.product(range(5), (0, 1))) diff --git a/third_party/quaff/quaff/json_resolver.py b/recirq/third_party/quaff/json_resolver.py similarity index 77% rename from third_party/quaff/quaff/json_resolver.py rename to recirq/third_party/quaff/json_resolver.py index 1a35647a..2acac26f 100644 --- a/third_party/quaff/quaff/json_resolver.py +++ b/recirq/third_party/quaff/json_resolver.py @@ -2,11 +2,13 @@ from cirq.protocols.json_serialization import ObjectFactory +from recirq.third_party import quaff + def json_resolver(quaff_type: str) -> Optional[ObjectFactory]: if quaff_type.startswith("quaff."): return cast( ObjectFactory, - eval(f"__import__('quaff').{quaff_type.split('.', 1)[1]}", {}, {}), + getattr(quaff, quaff_type[6:]) ) return None diff --git a/third_party/quaff/quaff/json_serialization.py b/recirq/third_party/quaff/json_serialization.py similarity index 100% rename from third_party/quaff/quaff/json_serialization.py rename to recirq/third_party/quaff/json_serialization.py diff --git a/third_party/quaff/quaff/linalg.py b/recirq/third_party/quaff/linalg.py similarity index 99% rename from third_party/quaff/quaff/linalg.py rename to recirq/third_party/quaff/linalg.py index 41e453c6..65a3e12a 100644 --- a/third_party/quaff/quaff/linalg.py +++ b/recirq/third_party/quaff/linalg.py @@ -1,7 +1,7 @@ from typing import Any, Callable, Iterable, Optional, Tuple, Union import numpy as np -from quaff import indexing +from recirq.third_party.quaff import indexing DTYPE = np.uint8 diff --git a/third_party/quaff/quaff/linalg_test.py b/recirq/third_party/quaff/linalg_test.py similarity index 99% rename from third_party/quaff/quaff/linalg_test.py rename to recirq/third_party/quaff/linalg_test.py index 26cfa402..68feeb18 100644 --- a/third_party/quaff/quaff/linalg_test.py +++ b/recirq/third_party/quaff/linalg_test.py @@ -3,7 +3,7 @@ import cirq import numpy as np import pytest -import quaff +from recirq.third_party import quaff @pytest.mark.parametrize( diff --git a/third_party/quaff/quaff/random.py b/recirq/third_party/quaff/random.py similarity index 97% rename from third_party/quaff/quaff/random.py rename to recirq/third_party/quaff/random.py index ea174e80..6a7ca39d 100644 --- a/third_party/quaff/quaff/random.py +++ b/recirq/third_party/quaff/random.py @@ -2,7 +2,7 @@ from typing import Optional, Tuple import numpy as np -from quaff import indexing, linalg, sampling +from recirq.third_party.quaff import indexing, linalg, sampling SEED = 2349230498 RNG = np.random.default_rng(SEED) diff --git a/third_party/quaff/quaff/random_test.py b/recirq/third_party/quaff/random_test.py similarity index 96% rename from third_party/quaff/quaff/random_test.py rename to recirq/third_party/quaff/random_test.py index dfa7c8aa..51872418 100644 --- a/third_party/quaff/quaff/random_test.py +++ b/recirq/third_party/quaff/random_test.py @@ -1,6 +1,6 @@ import numpy as np import pytest -import quaff +from recirq.third_party import quaff @pytest.mark.parametrize( diff --git a/third_party/quaff/quaff/sampling/__init__.py b/recirq/third_party/quaff/sampling/__init__.py similarity index 84% rename from third_party/quaff/quaff/sampling/__init__.py rename to recirq/third_party/quaff/sampling/__init__.py index 05d02c09..a5c7347d 100644 --- a/third_party/quaff/quaff/sampling/__init__.py +++ b/recirq/third_party/quaff/sampling/__init__.py @@ -1,4 +1,4 @@ -from quaff import testing +from recirq.third_party.quaff import testing from .boolean_sampler import BooleanSampler from .clifford_sampler import ( diff --git a/third_party/quaff/quaff/sampling/boolean_sampler.py b/recirq/third_party/quaff/sampling/boolean_sampler.py similarity index 89% rename from third_party/quaff/quaff/sampling/boolean_sampler.py rename to recirq/third_party/quaff/sampling/boolean_sampler.py index 6842eab5..1f14e738 100644 --- a/third_party/quaff/quaff/sampling/boolean_sampler.py +++ b/recirq/third_party/quaff/sampling/boolean_sampler.py @@ -2,8 +2,8 @@ from typing import Any, Iterable, Optional, Tuple import numpy as np -from quaff import linalg, testing -from quaff.sampling.sampler import Randomness, Sample, Sampler +from recirq.third_party.quaff import linalg, testing +from recirq.third_party.quaff.sampling.sampler import Randomness, Sample, Sampler class BooleanSampler(Sampler): diff --git a/third_party/quaff/quaff/sampling/clifford_sampler.py b/recirq/third_party/quaff/sampling/clifford_sampler.py similarity index 98% rename from third_party/quaff/quaff/sampling/clifford_sampler.py rename to recirq/third_party/quaff/sampling/clifford_sampler.py index ecf7379c..94038811 100644 --- a/third_party/quaff/quaff/sampling/clifford_sampler.py +++ b/recirq/third_party/quaff/sampling/clifford_sampler.py @@ -5,8 +5,8 @@ import cirq import numpy as np -from quaff import comb, indexing, linalg, testing -from quaff.sampling.sampler import SingleParameterSampler +from recirq.third_party.quaff import comb, indexing, linalg, testing +from recirq.third_party.quaff.sampling.sampler import SingleParameterSampler QuantumMallowsSample = Tuple[Tuple[bool, ...], Tuple[int, ...]] QuantumMallowsRandomness = Tuple[int, ...] diff --git a/third_party/quaff/quaff/sampling/invertible_matrix_sampler.py b/recirq/third_party/quaff/sampling/invertible_matrix_sampler.py similarity index 97% rename from third_party/quaff/quaff/sampling/invertible_matrix_sampler.py rename to recirq/third_party/quaff/sampling/invertible_matrix_sampler.py index 20c1ad0f..f52b8990 100644 --- a/third_party/quaff/quaff/sampling/invertible_matrix_sampler.py +++ b/recirq/third_party/quaff/sampling/invertible_matrix_sampler.py @@ -3,8 +3,8 @@ from typing import Any, Iterable, Optional, Tuple, cast import numpy as np -from quaff import comb, indexing, linalg -from quaff.sampling.sampler import SingleParameterSampler +from recirq.third_party.quaff import comb, indexing, linalg +from recirq.third_party.quaff.sampling.sampler import SingleParameterSampler MallowsSample = Tuple[int, ...] MallowsRandomness = Tuple[int, ...] diff --git a/third_party/quaff/quaff/sampling/sampler.py b/recirq/third_party/quaff/sampling/sampler.py similarity index 100% rename from third_party/quaff/quaff/sampling/sampler.py rename to recirq/third_party/quaff/sampling/sampler.py diff --git a/third_party/quaff/quaff/sampling/testing.py b/recirq/third_party/quaff/sampling/testing.py similarity index 92% rename from third_party/quaff/quaff/sampling/testing.py rename to recirq/third_party/quaff/sampling/testing.py index b1dd21d5..6cd406ed 100644 --- a/third_party/quaff/quaff/sampling/testing.py +++ b/recirq/third_party/quaff/sampling/testing.py @@ -2,8 +2,8 @@ import numpy as np import scipy.stats -from quaff import json_serialization, random -from quaff.testing import assert_equivalent_repr +from recirq.third_party.quaff import json_serialization, random +from recirq.third_party.quaff.testing import assert_equivalent_repr def assert_sampler_consistent(sampler_cls, *args, test_json=False, **kwargs): diff --git a/third_party/quaff/quaff/testing.py b/recirq/third_party/quaff/testing.py similarity index 97% rename from third_party/quaff/quaff/testing.py rename to recirq/third_party/quaff/testing.py index bce76d1f..a3bac857 100644 --- a/third_party/quaff/quaff/testing.py +++ b/recirq/third_party/quaff/testing.py @@ -2,7 +2,7 @@ import cirq import numpy as np -from quaff import linalg +from recirq.third_party.quaff import linalg def assert_consistent_unitary_round_trip(num_qubits, gate_type, seed): diff --git a/setup.py b/setup.py index e5539716..fe60e388 100644 --- a/setup.py +++ b/setup.py @@ -58,5 +58,7 @@ def _parse_requirements(path: pathlib.Path): 'hfvqe/molecular_data/hydrogen_chains/*/*/*', # Needed for ftbbl docs 'otoc/loschmidt/tilted_square_lattice/*', + # Needed for qcqmc notebooks + 'qcqmc/data/integrals/*/*', ]}, ) diff --git a/third_party/quaff/quaff/gates/__init__.py b/third_party/quaff/quaff/gates/__init__.py deleted file mode 100644 index a2a957ee..00000000 --- a/third_party/quaff/quaff/gates/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -from quaff.gates.fhf import FHFGate -from quaff.gates.hadamard_free import HadamardFreeGate -from quaff.gates.parameterized import ( - get_parameterized_truncated_clifford_ops, - get_parameterized_truncated_cliffords_ops, - get_truncated_clifford_resolver, - get_truncated_cliffords_resolver, -) -from quaff.gates.single_qubit_layer import SingleQubitLayerGate -from quaff.gates.truncated_clifford import TruncatedCliffordGate diff --git a/third_party/quaff/requirements.txt b/third_party/quaff/requirements.txt deleted file mode 100644 index 7de75efd..00000000 --- a/third_party/quaff/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -numpy -scipy -cirq-core \ No newline at end of file diff --git a/third_party/quaff/setup.py b/third_party/quaff/setup.py deleted file mode 100644 index a7f45498..00000000 --- a/third_party/quaff/setup.py +++ /dev/null @@ -1,20 +0,0 @@ -import pathlib - -from setuptools import find_packages, setup - - -def _parse_requirements(path: pathlib.Path): - lines = [line.strip() for line in path.read_text().splitlines() if line] - return [line for line in lines if not line.startswith("#")] - - -install_requires = _parse_requirements(pathlib.Path("requirements.txt")) -setup( - name="quaff", - version="0.0.0", - author="Bryan A. O'Gorman", - install_requires=install_requires, - license="Apache 2", - long_description=open("README.md", encoding="utf-8").read(), - packages=find_packages(), -)