Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions .github/workflows/build-changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ jobs:
python -m pip install --upgrade pip
python -m pip install '.[dev]'
- name: Run all checks
run: checks/pytest_.py
run: python checks/pytest_.py

windows:
name: Windows check
if: github.event.pull_request.draft == false
runs-on: windows-latest
timeout-minutes: 5
env:
UV_SYSTEM_PYTHON: 1 # needed because 'uv sync ...' followed by 'uv run ...' does not work...
steps:
- uses: actions/checkout@v6
- name: Set up Python
Expand All @@ -51,8 +53,6 @@ jobs:
cache-dependency-glob: |
**/pyproject.toml
- name: Install package and dependencies
run: uv sync --extra dev
run: uv pip install -e ".[dev]"
- name: Run all checks
shell: cmd
run: |
uv run python checks/pytest_.py
run: python checks/pytest_.py
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ dependencies = [
"sympy>=1.12",
]

# TODO: update relay-bp to
# "relay-bp[stim]==0.2.?",
# once https://github.com/trmue/relay/pull/30 is in a release
[project.optional-dependencies]
dev = [
"checks-superstaq>=0.5.45",
Expand Down
2 changes: 1 addition & 1 deletion src/qldpc/circuits/common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_state_prep(pytestconfig: pytest.Config) -> None:
codes_to_test = [
codes.FiveQubitCode(),
codes.BaconShorCode(3),
codes.HGPCode(codes.ClassicalCode.random(5, 3, seed=np.random.randint(2**32 - 1))),
codes.HGPCode(codes.ClassicalCode.random(5, 3, seed=np.random.randint(2**31))),
]

for code, only_zero in itertools.product(codes_to_test, [True, False]):
Expand Down
6 changes: 3 additions & 3 deletions src/qldpc/codes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def __contains__(
@functools.cached_property
def canonicalized(self) -> ClassicalCode:
"""The same code with its parity matrix in reduced row echelon form."""
if self._is_canonicalized:
if self._is_canonicalized: # pragma: no cover
return self
matrix_rref = self.matrix.row_reduce()
matrix_rref = matrix_rref[np.any(matrix_rref, axis=1), :]
Expand Down Expand Up @@ -885,7 +885,7 @@ def is_subsystem_code(self) -> bool:
@functools.cached_property
def canonicalized(self) -> QuditCode:
"""The same code with its parity matrix in reduced row echelon form."""
if self._is_canonicalized:
if self._is_canonicalized: # pragma: no cover
return self
matrix_rref = self.matrix.row_reduce()
matrix_rref = matrix_rref[np.any(matrix_rref, axis=1), :]
Expand Down Expand Up @@ -2146,7 +2146,7 @@ def is_subsystem_code(self) -> bool:
@functools.cached_property
def canonicalized(self) -> CSSCode:
"""The same code with its parity matrices in reduced row echelon form."""
if self._is_canonicalized:
if self._is_canonicalized: # pragma: no cover
return self
code = CSSCode(
self.code_x.canonicalized,
Expand Down
9 changes: 5 additions & 4 deletions src/qldpc/codes/common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_constructions_classical(pytestconfig: pytest.Config) -> None:
"""Classical code constructions."""
np.random.seed(pytestconfig.getoption("randomly_seed"))

code = codes.ClassicalCode.random(5, 3, seed=np.random.randint(2**32))
code = codes.ClassicalCode.random(5, 3, seed=np.random.randint(2**31))
assert len(code) == code.num_bits == 5
assert code.num_checks == 3
assert "ClassicalCode" in str(code)
Expand All @@ -48,7 +48,7 @@ def test_constructions_classical(pytestconfig: pytest.Config) -> None:
code.set_generator(np.roll(code.generator, shift=1, axis=0))
assert codes.ClassicalCode(code).generator is code.generator

code = codes.ClassicalCode.random(5, 3, field=3, seed=np.random.randint(2**32))
code = codes.ClassicalCode.random(5, 3, field=3, seed=np.random.randint(2**31))
assert "GF(3)" in str(code)

code = codes.RepetitionCode(2, field=3)
Expand All @@ -75,6 +75,7 @@ def test_constructions_classical(pytestconfig: pytest.Config) -> None:
code = codes.ClassicalCode.random(6, 4, field=field)
bits_to_remove = np.random.choice(range(len(code)), size=2, replace=False)
bits_to_keep = [bit for bit in range(len(code)) if bit not in bits_to_remove]
code._matrix[:2, bits_to_remove] = 1 # ensure we have nontrivial row-reduction to do
punctured_code = code.punctured(bits_to_remove)
assert punctured_code.is_equiv_to(
codes.ClassicalCode.from_generator(code.generator[:, bits_to_keep])
Expand All @@ -86,8 +87,8 @@ def test_constructions_classical(pytestconfig: pytest.Config) -> None:
assert np.array_equal(list(code.shortened([0]).iter_words()), [[0, 0]])

# stack two codes
code_a = codes.ClassicalCode.random(5, 3, field=3, seed=np.random.randint(2**32))
code_b = codes.ClassicalCode.random(5, 3, field=3, seed=np.random.randint(2**32))
code_a = codes.ClassicalCode.random(5, 3, field=3, seed=np.random.randint(2**31))
code_b = codes.ClassicalCode.random(5, 3, field=3, seed=np.random.randint(2**31))
code = codes.ClassicalCode.stack([code_a, code_b])
assert len(code) == len(code_a) + len(code_b)
assert code.dimension == code_a.dimension + code_b.dimension
Expand Down
2 changes: 1 addition & 1 deletion src/qldpc/codes/distance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_count_trailing_zeros(base_val: int) -> None:

@pytest.mark.parametrize("width", range(1, 8))
def test_inplace_rowsum(width: int) -> None:
arr = np.random.randint(2**32, size=(10, width), dtype=np.uint)
arr = np.random.randint(2**31, size=(10, width), dtype=np.uint)
expected = arr.sum(-1)
actual = qldpc.codes.distance._inplace_rowsum(arr)
np.testing.assert_array_equal(actual, expected)
Expand Down
14 changes: 7 additions & 7 deletions src/qldpc/codes/quantum_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ def test_hypergraph_product(
"""Equivalency of matrix-based, graph-based, and chain-based hypergraph products."""
np.random.seed(pytestconfig.getoption("randomly_seed"))

code_a = codes.ClassicalCode.random(*bits_checks_a, field=field, seed=np.random.randint(2**32))
code_b = codes.ClassicalCode.random(*bits_checks_b, field=field, seed=np.random.randint(2**32))
code_a = codes.ClassicalCode.random(*bits_checks_a, field=field, seed=np.random.randint(2**31))
code_b = codes.ClassicalCode.random(*bits_checks_b, field=field, seed=np.random.randint(2**31))

code = codes.HGPCode(code_a, code_b, set_logicals=True)
graph = codes.HGPCode.get_graph_product(code_a.graph, code_b.graph)
Expand All @@ -270,8 +270,8 @@ def test_subsystem_hypergraph_product(
"""Validity of the subsystem hypergraph product code."""
np.random.seed(pytestconfig.getoption("randomly_seed"))

code_a = codes.ClassicalCode.random(*bits_checks_a, field=field, seed=np.random.randint(2**32))
code_b = codes.ClassicalCode.random(*bits_checks_b, field=field, seed=np.random.randint(2**32))
code_a = codes.ClassicalCode.random(*bits_checks_a, field=field, seed=np.random.randint(2**31))
code_b = codes.ClassicalCode.random(*bits_checks_b, field=field, seed=np.random.randint(2**31))
code = codes.SHPCode(code_a, code_b, set_logicals=True)

# assert validity of the the "natural" stabilizers that are set at initialization time
Expand All @@ -293,8 +293,8 @@ def test_trivial_lift(
"""The lifted product code with a trivial lift reduces to the HGP code."""
np.random.seed(pytestconfig.getoption("randomly_seed"))

code_a = codes.ClassicalCode.random(*bits_checks_a, field=field, seed=np.random.randint(2**32))
code_b = codes.ClassicalCode.random(*bits_checks_b, field=field, seed=np.random.randint(2**32))
code_a = codes.ClassicalCode.random(*bits_checks_a, field=field, seed=np.random.randint(2**31))
code_b = codes.ClassicalCode.random(*bits_checks_b, field=field, seed=np.random.randint(2**31))
code_HGP = codes.HGPCode(code_a, code_b, field)

matrix_a = abstract.TrivialGroup.to_ring_array(code_a.matrix)
Expand Down Expand Up @@ -408,7 +408,7 @@ def test_quantum_tanner(pytestconfig: pytest.Config) -> None:
# random quantum Tanner code
group = abstract.CyclicGroup(12)
subcode = codes.RepetitionCode(4, field=3)
code = codes.QTCode.random(group, subcode, seed=np.random.randint(2**32))
code = codes.QTCode.random(group, subcode, seed=np.random.randint(2**31))

# assert that subgraphs have the right number of nodes, edges, and node degrees
subgraph_x, subgraph_z = codes.QTCode.get_subgraphs(code.complex)
Expand Down