Skip to content

feat: add compute_output_permutation utility#63

Merged
dlyongemallo merged 1 commit into
mainfrom
add_compute_output_permutation
Apr 21, 2026
Merged

feat: add compute_output_permutation utility#63
dlyongemallo merged 1 commit into
mainfrom
add_compute_output_permutation

Conversation

@dlyongemallo

@dlyongemallo dlyongemallo commented Apr 18, 2026

Copy link
Copy Markdown
Owner

Relates to #18.

Copilot AI review requested due to automatic review settings April 18, 2026 07:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new utility to read the qubit output permutation left behind by PyZX extraction when using up_to_perm=True, along with unit tests intended to validate the behavior.

Changes:

  • Add compute_output_permutation(g) utility in zxpass/zxpass.py.
  • Add tests for basic permutation properties, identity case, and a “matches swaps” scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
zxpass/zxpass.py Introduces compute_output_permutation to derive output→input mapping from a post-extraction graph.
test/test_zxpass.py Adds new tests covering the new permutation utility and extraction behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread zxpass/zxpass.py
Comment thread test/test_zxpass.py
Comment thread test/test_zxpass.py Outdated
Comment thread test/test_zxpass.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a small utility to interpret PyZX’s post-extraction boundary connectivity as an explicit qubit permutation, with accompanying unit tests to validate behavior against extract_circuit(up_to_perm=...).

Changes:

  • Add compute_output_permutation() to derive an output→input qubit index mapping from a post-extraction PyZX graph.
  • Add tests exercising the utility on reduced/extracted graphs and cross-checking against SWAP insertion behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
zxpass/zxpass.py Introduces compute_output_permutation() with validation and error reporting.
test/test_zxpass.py Adds tests for the new permutation utility, including an equivalence check via SWAP reconstruction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread zxpass/zxpass.py
Comment thread zxpass/zxpass.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a small helper utility to interpret PyZX’s post-extraction boundary graph connectivity and expose the resulting output-to-input qubit permutation, with accompanying tests to validate expected behavior and error handling.

Changes:

  • Add compute_output_permutation(g) to derive {output_qubit_index: input_qubit_index} from a post-extraction graph (up_to_perm=True).
  • Add unit tests covering normal operation, identity cases, SWAP equivalence, and several invalid-graph error branches.
  • Update test module imports/lint settings to support the expanded test suite.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
zxpass/zxpass.py Introduces compute_output_permutation utility for reading boundary connectivity after PyZX extraction.
test/test_zxpass.py Adds a comprehensive test suite for the new utility, including error-case validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/test_zxpass.py
@dlyongemallo dlyongemallo merged commit 6d18e28 into main Apr 21, 2026
8 checks passed
@dlyongemallo dlyongemallo deleted the add_compute_output_permutation branch April 21, 2026 07:09
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.

2 participants