Skip to content

Commit

Permalink
Update path.
Browse files Browse the repository at this point in the history
  • Loading branch information
fdmalone committed Jun 13, 2024
1 parent 30a4389 commit 2ad0063
Show file tree
Hide file tree
Showing 30 changed files with 72 additions and 58 deletions.
Empty file added recirq/third_party/__init__.py
Empty file.
12 changes: 9 additions & 3 deletions recirq/third_party/quaff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from recirq.qcqmc.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
Expand Down Expand Up @@ -66,8 +72,8 @@


def _register_resolver() -> None:
from recirq.qcqmc.quaff.json_resolver import json_resolver
from recirq.qcqmc.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)

Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/basis_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import cirq
import numpy as np

from recirq.qcqmc.quaff import indexing, linalg, random
from recirq.third_party.quaff import indexing, linalg, random


class BasisChangeGate(cirq.Gate):
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/basis_change_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import pytest

from recirq.qcqmc import quaff
from recirq.third_party import quaff


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/comb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import pytest

from recirq.qcqmc import quaff
from recirq.third_party import quaff


def test_get_num_perms_with_inversion_number():
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/cz_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import cirq
import numpy as np

from recirq.qcqmc.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):
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/cz_layer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pytest

from recirq.qcqmc import quaff
from recirq.third_party import quaff


@pytest.mark.parametrize(
Expand Down
10 changes: 5 additions & 5 deletions recirq/third_party/quaff/gates/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from recirq.qcqmc.quaff.gates.fhf import FHFGate
from recirq.qcqmc.quaff.gates.hadamard_free import HadamardFreeGate
from recirq.qcqmc.quaff.gates.parameterized import (
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.qcqmc.quaff.gates.single_qubit_layer import SingleQubitLayerGate
from recirq.qcqmc.quaff.gates.truncated_clifford import TruncatedCliffordGate
from recirq.third_party.quaff.gates.single_qubit_layer import SingleQubitLayerGate
from recirq.third_party.quaff.gates.truncated_clifford import TruncatedCliffordGate
8 changes: 4 additions & 4 deletions recirq/third_party/quaff/gates/fhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import cirq
import numpy as np

from recirq.qcqmc.quaff import linalg, sampling, testing
from recirq.qcqmc.quaff.gates.hadamard_free import HadamardFreeGate
from recirq.qcqmc.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]:
Expand Down Expand Up @@ -67,7 +67,7 @@ def _json_dict_(self):

@classmethod
def _json_namespace_(cls):
return "recirq.qcqmc.quaff"
return "recirq.third_party.quaff"

def _num_qubits_(self):
return self._num_qubits
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/gates/fhf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pytest

from recirq.qcqmc import quaff
from recirq.third_party import quaff


@pytest.mark.parametrize("n, seed", ((n, quaff.random_seed()) for n in range(1, 7)))
Expand Down
4 changes: 2 additions & 2 deletions recirq/third_party/quaff/gates/hadamard_free.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import cirq
import numpy as np

from recirq.qcqmc.quaff import indexing, linalg, random, testing
from recirq.third_party.quaff import indexing, linalg, random, testing


@dataclass
Expand Down Expand Up @@ -47,7 +47,7 @@ def _json_dict_(self):

@classmethod
def _json_namespace_(cls):
return "recirq.qcqmc.quaff"
return "recirq.third_party.quaff"

def _num_qubits_(self):
return self._num_qubits
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/gates/hadamard_free_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pytest

from recirq.qcqmc import quaff
from recirq.third_party import quaff


def assert_hadamard_free_gate_unitary_is_good(n, gate):
Expand Down
4 changes: 2 additions & 2 deletions recirq/third_party/quaff/gates/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import cirq
import sympy

from recirq.qcqmc.quaff import cz_layer
from recirq.qcqmc.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(
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/gates/parameterized_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pytest

from recirq.qcqmc import quaff
from recirq.third_party import quaff


@pytest.mark.parametrize("n, seed", ((n, quaff.random_seed()) for n in range(1, 6)))
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/gates/single_qubit_layer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import pytest

from recirq.qcqmc import quaff
from recirq.third_party import quaff


def test_single_qubit_layer_gate_bad():
Expand Down
12 changes: 6 additions & 6 deletions recirq/third_party/quaff/gates/truncated_clifford.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import cirq
import numpy as np

from recirq.qcqmc.quaff import comb, cz_layer, indexing, linalg, sampling, testing
from recirq.qcqmc.quaff.gates.fhf import FHFGate
from recirq.qcqmc.quaff.gates.hadamard_free import HadamardFreeGate
from recirq.qcqmc.quaff.gates.single_qubit_layer import SingleQubitLayerGate
from recirq.qcqmc.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)
Expand Down Expand Up @@ -54,7 +54,7 @@ def _json_dict_(self):

@classmethod
def _json_namespace_(cls):
return "recirq.qcqmc.quaff"
return "recirq.third_party.quaff"

def __str__(self):
args = [f"n={self._num_qubits}"]
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/gates/truncated_clifford_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import pytest

from recirq.qcqmc.quaff import (
from recirq.third_party.quaff import (
DEFAULT_RESOLVERS,
HadamardFreeGate,
random_seed,
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/indexing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pytest

from recirq.qcqmc import quaff
from recirq.third_party import quaff


@pytest.mark.parametrize("n, big_endian", itertools.product(range(5), (0, 1)))
Expand Down
10 changes: 7 additions & 3 deletions recirq/third_party/quaff/json_resolver.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from typing import cast, Optional
from typing import Optional, cast

from cirq.protocols.json_serialization import ObjectFactory


def json_resolver(quaff_type: str) -> Optional[ObjectFactory]:
if quaff_type.startswith("recirq.qcqmc.quaff."):
if quaff_type.startswith("recirq.third_party.quaff."):
return cast(
ObjectFactory,
eval(f"__import__('recirq.qcqmc').{quaff_type.split('.', 1)[1]}", {}, {}),
eval(
f"__import__('recirq.third_party').{quaff_type.split('.', 1)[1]}",
{},
{},
),
)
return None
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

from recirq.qcqmc.quaff import indexing
from recirq.third_party.quaff import indexing

DTYPE = np.uint8

Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/linalg_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pytest

from recirq.qcqmc import quaff
from recirq.third_party import quaff


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

from recirq.qcqmc.quaff import indexing, linalg, sampling
from recirq.third_party.quaff import indexing, linalg, sampling

SEED = 2349230498
RNG = np.random.default_rng(SEED)
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/random_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import pytest

from recirq.qcqmc import quaff
from recirq.third_party import quaff


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/sampling/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from recirq.qcqmc.quaff import testing
from recirq.third_party.quaff import testing

from .boolean_sampler import BooleanSampler
from .clifford_sampler import (
Expand Down
4 changes: 2 additions & 2 deletions recirq/third_party/quaff/sampling/boolean_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import numpy as np

from recirq.qcqmc.quaff import linalg, testing
from recirq.qcqmc.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):
Expand Down
22 changes: 13 additions & 9 deletions recirq/third_party/quaff/sampling/clifford_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import cirq
import numpy as np

from recirq.qcqmc.quaff import comb, indexing, linalg, testing
from recirq.qcqmc.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, ...]
Expand Down Expand Up @@ -120,7 +120,7 @@ def _json_dict_(self):

@classmethod
def _json_namespace_(cls):
return "recirq.qcqmc.quaff"
return "recirq.third_party.quaff"

def num_qubits(self):
return len(self.parity_shift)
Expand Down Expand Up @@ -189,12 +189,16 @@ def _get_Δ_and_Γ_indices(
else:
Δ_indices.append((i, j))
return (
tuple(np.array(Δ_indices).T)
if Δ_indices
else (np.zeros(0, dtype=int),) * 2,
tuple(np.array(Γ_indices).T)
if Γ_indices
else (np.zeros(0, dtype=int),) * 2,
(
tuple(np.array(Δ_indices).T)
if Δ_indices
else (np.zeros(0, dtype=int),) * 2
),
(
tuple(np.array(Γ_indices).T)
if Γ_indices
else (np.zeros(0, dtype=int),) * 2
),
)

def randomness_to_sample(self, randomness: CliffordRandomness) -> CliffordSample:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import numpy as np

from recirq.qcqmc.quaff import comb, indexing, linalg
from recirq.qcqmc.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, ...]
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/sampling/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __str__(self):
return f"{self.name()}({arg_str})"

def __repr__(self):
return f"recirq.qcqmc.quaff.{self}"
return f"recirq.third_party.quaff.{self}"

def __eq__(self, other):
if not isinstance(other, type(self)):
Expand Down
4 changes: 2 additions & 2 deletions recirq/third_party/quaff/sampling/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import numpy as np
import scipy.stats

from recirq.qcqmc.quaff import json_serialization, random
from recirq.qcqmc.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):
Expand Down
2 changes: 1 addition & 1 deletion recirq/third_party/quaff/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import cirq
import numpy as np

from recirq.qcqmc.quaff import linalg
from recirq.third_party.quaff import linalg


def assert_consistent_unitary_round_trip(num_qubits, gate_type, seed):
Expand Down

0 comments on commit 2ad0063

Please sign in to comment.