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
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ruff==0.15.0
ruff==0.15.1
mypy==1.19.1
pyright==1.1.408
pytest==9.0.2
Expand Down
7 changes: 4 additions & 3 deletions tests/test_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import itertools
import math

import numpy as np
import pytest
Expand Down Expand Up @@ -42,7 +43,7 @@ def test_mbqc_circuit_j_gate() -> None:
assert len(instructions) == 1
assert isinstance(instructions[0], J)
assert instructions[0].qubit == 0
assert instructions[0].angle == 0.5
assert math.isclose(instructions[0].angle, 0.5)


def test_mbqc_circuit_cz_gate() -> None:
Expand All @@ -63,7 +64,7 @@ def test_mbqc_circuit_phase_gadget() -> None:
assert len(instructions) == 1
assert isinstance(instructions[0], PhaseGadget)
assert instructions[0].qubits == [0, 1, 3]
assert instructions[0].angle == 0.25
assert math.isclose(instructions[0].angle, 0.25)


def test_mbqc_circuit_multiple_gates() -> None:
Expand Down Expand Up @@ -277,7 +278,7 @@ def test_circuit2graph_phase_gadget_circuit() -> None:
basis = graph.meas_bases[pg_node]
assert isinstance(basis, PlannerMeasBasis)
assert basis.plane == Plane.YZ
assert basis.angle == 0.25
assert math.isclose(basis.angle, 0.25)


def test_circuit2graph_empty_circuit() -> None:
Expand Down
6 changes: 4 additions & 2 deletions tests/test_graphstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

import math

import numpy as np
import pytest

Expand Down Expand Up @@ -187,10 +189,10 @@ def test_register_output_raises_1(graph: GraphState) -> None:
def test_assign_meas_basis(graph: GraphState) -> None:
"""Test setting the measurement basis of a physical node."""
node_index = graph.add_physical_node()
meas_basis = PlannerMeasBasis(Plane.XZ, 0.5 * np.pi)
meas_basis = PlannerMeasBasis(Plane.XZ, 0.5 * math.pi)
graph.assign_meas_basis(node_index, meas_basis)
assert graph.meas_bases[node_index].plane == Plane.XZ
assert graph.meas_bases[node_index].angle == 0.5 * np.pi
assert math.isclose(graph.meas_bases[node_index].angle, 0.5 * math.pi)


def test_check_canonical_form_true(canonical_graph: GraphState) -> None:
Expand Down
10 changes: 6 additions & 4 deletions tests/test_graphstate_bulk_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

import math

import pytest

from graphqomb.common import Plane, PlannerMeasBasis
Expand Down Expand Up @@ -90,9 +92,9 @@ def test_from_graph_with_meas_bases() -> None:
assert node_map[nodes[2]] not in gs.meas_bases
# Check that the measurement bases have the correct attributes
assert gs.meas_bases[node_map[nodes[0]]].plane == Plane.XY
assert gs.meas_bases[node_map[nodes[0]]].angle == 0.0
assert math.isclose(gs.meas_bases[node_map[nodes[0]]].angle, 0.0)
assert gs.meas_bases[node_map[nodes[1]]].plane == Plane.XY
assert gs.meas_bases[node_map[nodes[1]]].angle == 1.5708
assert math.isclose(gs.meas_bases[node_map[nodes[1]]].angle, 1.5708)


def test_from_graph_with_partial_meas_bases() -> None:
Expand Down Expand Up @@ -190,9 +192,9 @@ def test_from_base_graph_state_simple() -> None:
assert 0 in dst.meas_bases
assert 1 in dst.meas_bases
assert dst.meas_bases[0].plane == Plane.XY
assert dst.meas_bases[0].angle == 0.0
assert math.isclose(dst.meas_bases[0].angle, 0.0)
assert dst.meas_bases[1].plane == Plane.XY
assert dst.meas_bases[1].angle == 1.5708
assert math.isclose(dst.meas_bases[1].angle, 1.5708)


def test_from_base_graph_state_preserves_indices() -> None:
Expand Down
4 changes: 3 additions & 1 deletion tests/test_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

import math

import pytest

from graphqomb.command import TICK, E, M, N, X, Z
Expand Down Expand Up @@ -320,7 +322,7 @@ def test_throughput_calculates_measurements_per_tick(
pauli_frame=pauli_frame,
)

assert pattern.throughput == 2 / 4
assert math.isclose(pattern.throughput, 2 / 4)


def test_throughput_raises_for_zero_depth(
Expand Down