Skip to content

Conversation

@d1ssk
Copy link
Collaborator

@d1ssk d1ssk commented May 12, 2025

Before submitting, please check the following:

  • Make sure you have tests for the new code and that test passes (run pytest)
  • If applicable, add a line to the [unreleased] part of CHANGELOG.md, following keep-a-changelog.
  • Format added code by ruff
  • Type checking by mypy and pyright
  • Make sure the checks (github actions) pass.
  • Check that the docs compile without errors (run make html in ./docs/ - you may need to install dependency for sphinx docs, see docs/requirements.txt.)

Then, please fill in below:

Context (if applicable):
Implement circuit extraction algorithm in Backens et al (2021)

Description of the change:

Related issue:
#32

@masa10-f masa10-f changed the base branch from master to mf May 12, 2025 10:35
@masa10-f
Copy link
Collaborator

I changed the base branch from master to mf

depth: int,
rng: np.random.Generator | None = None,
edge_p: float = 0.5,
angle_list: list | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use an appropriate collections.abc stuff rather than list .

depth: int,
rng: np.random.Generator | None = None,
edge_p: float = 0.5,
angle_list: list | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

_list is unnecessary because it's obvious that it should be list from the annotation.

generated MBQC circuit
"""
if rng is None:
rng = np.random.default_rng()
Copy link
Collaborator

Choose a reason for hiding this comment

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

MEMO: it's better to cache rng as in graphix, because PRNG is designed to reduce correlations between samples drawn from the same generator instance.

self.pivot(*pair)
del pair
continue
if u := self._extract_xz_node():
Copy link
Collaborator

Choose a reason for hiding this comment

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

is None is preferable because 0 is also falthy.

assert _is_close_angle(result_basis.angle, ref_angle)


@pytest.mark.parametrize("plane", [Plane.XY, Plane.YZ, Plane.XZ])
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can directly iterate Plane as list(Plane) .

dict[int, int]
inner index to node index mapping.
"""
return self.__inner2nodes
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it OK to expose internal states?

n, m = M.shape
row_ops: List[Tuple[int,int]] = []
pivot_row = 0
for col in range(m):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Too complex.

_process_frontier(d, frontier, circ)


def _gauss_elim(M: np.ndarray) -> Tuple[np.ndarray, List[Tuple[int,int]]]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please respect PEP8.

@@ -0,0 +1,161 @@
from typing import Set, List, Tuple
Copy link
Collaborator

Choose a reason for hiding this comment

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

Deprecated.

def test_prune_non_cliffords(
zx_graph: ZXGraphState,
initial_zxgraph: tuple[range, set[tuple[int, int]]],
measurements: list[tuple[int, Plane, float]],
Copy link
Collaborator

Choose a reason for hiding this comment

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

ABC please.

@d1ssk d1ssk marked this pull request as draft July 1, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants