Skip to content

Add expectation and trace to tableau python bindings#176

Open
david-pl wants to merge 2 commits into
mainfrom
feat/generalized-tableau-trace-expect
Open

Add expectation and trace to tableau python bindings#176
david-pl wants to merge 2 commits into
mainfrom
feat/generalized-tableau-trace-expect

Conversation

@david-pl

@david-pl david-pl commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

This wasn't added as part of #172, but should be exposed in python too.

Copilot AI review requested due to automatic review settings July 9, 2026 09:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Exposes the Rust GeneralizedTableau Pauli expectation (⟨ψ|P|ψ⟩) and summed-pattern trace (Σ⟨ψ|P|ψ⟩) APIs through the Python bindings, and adds Python tests to validate basic correctness on small states (|0⟩, |+⟩, Bell, and a single-qubit ry rotation).

Changes:

  • Added GeneralizedTableau.expectation(word: str) -> float and GeneralizedTableau.trace(pattern: str) -> float to the Python wrapper.
  • Extended the native PyO3 interface to call inner.expectation(...) / inner.trace(...).
  • Added pytest coverage for expectation/trace on representative states and patterns.

Reviewed changes

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

File Description
ppvm-python/test/generalized_tableau/test_expectation.py Adds Python tests for expectation and trace on
ppvm-python/src/ppvm/generalized_tableau.py Adds Python-level convenience methods + docstrings for expectation and trace.
ppvm-python/src/ppvm/_core.pyi Updates native-module type stubs to include expectation and trace.
crates/ppvm-python-native/src/interface_tableau.rs Adds PyO3 methods to expose expectation/trace from the Rust tableau.

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

Comment thread crates/ppvm-python-native/src/interface_tableau.rs
Comment thread crates/ppvm-python-native/src/interface_tableau.rs
Comment thread ppvm-python/src/ppvm/generalized_tableau.py Outdated
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://QuEraComputing.github.io/ppvm/pr-preview/pr-176/

Built to branch gh-pages at 2026-07-10 07:25 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

The GeneralizedTableau.expectation docstring advertised "X0Y1" (which
panics on the digit) and claimed underscores are ignored (they are
dropped from bit placement but still inflate nqubits). Document the
actual accepted syntax: a dense I/X/Y/Z string whose length equals the
qubit count.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 10, 2026 07:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread crates/ppvm-python-native/src/interface_tableau.rs
Comment thread ppvm-python/test/generalized_tableau/test_expectation.py
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