Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rust decoder for .qgraph files (pyzx/quantomatic graph format) #22

Merged
merged 13 commits into from
Mar 31, 2024
Merged
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/v')"
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs: [linux, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v4
Expand Down
224 changes: 224 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ rand = "0.8.3"
rayon = "1.5.0"
regex = "1.4.3"
rustc-hash = "1.1.0"
derive_more = "0.99.17"
rstest = "0.18.2"
serde = "1.0.196"
serde_json = "1.0.113"
thiserror = "1.0.57"

[workspace.package]
version = "0.1.0"
Expand Down
17 changes: 14 additions & 3 deletions pybindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,13 @@ impl VecGraph {

fn vertex_type(&self, v: usize) -> u8 {
match self.g.vertex_type(v) {
VType::B => 0,
VType::Z => 1,
VType::X => 2,
VType::H => 3,
VType::B => 0,
VType::WInput => 4,
VType::WOutput => 5,
VType::ZBox => 6,
}
}

Expand All @@ -216,6 +219,9 @@ impl VecGraph {
1 => VType::Z,
2 => VType::X,
3 => VType::H,
4 => VType::WInput,
5 => VType::WOutput,
6 => VType::ZBox,
_ => VType::B,
};
self.g.set_vertex_type(v, ty);
Expand All @@ -225,13 +231,18 @@ impl VecGraph {
match self.g.edge_type_opt(e.0, e.1) {
Some(EType::N) => 1,
Some(EType::H) => 2,
Some(EType::Wio) => 3,
None => 0,
}
}

fn set_edge_type(&mut self, e: (usize, usize), et_num: u8) {
self.g
.set_edge_type(e.0, e.1, if et_num == 2 { EType::H } else { EType::N });
let et = match et_num {
2 => EType::H,
3 => EType::Wio,
_ => EType::N,
};
self.g.set_edge_type(e.0, e.1, et);
}

fn phase(&self, v: usize) -> (i64, i64) {
Expand Down
9 changes: 8 additions & 1 deletion quizx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[package]
name = "quizx"
default-example = "hidden_shift_stabrank"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
Expand All @@ -18,3 +17,11 @@ regex = { workspace = true }
rand = { workspace = true }
itertools = { workspace = true }
openqasm = { workspace = true }
thiserror = { workspace = true }
rstest = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
derive_more = { workspace = true }

[dev-dependencies]
rstest = { workspace = true }
Loading
Loading