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: Expand the Command API with iterators and helpers. #100

Merged
merged 16 commits into from
Sep 20, 2023
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
6 changes: 1 addition & 5 deletions compile-matcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ use std::fs;
use std::path::Path;

use clap::Parser;
use hugr::hugr::views::{HierarchyView, SiblingGraph};
use hugr::ops::handle::DfgID;
use hugr::HugrView;
use itertools::Itertools;

use tket2::json::load_tk1_json_file;
Expand Down Expand Up @@ -65,9 +62,8 @@ fn main() {
let patterns = all_circs
.iter()
.filter_map(|circ| {
let circ: SiblingGraph<'_, DfgID> = SiblingGraph::new(circ, circ.root());
croyzor marked this conversation as resolved.
Show resolved Hide resolved
// Fail silently on empty or disconnected patterns
CircuitPattern::try_from_circuit(&circ).ok()
CircuitPattern::try_from_circuit(circ).ok()
})
.collect_vec();
println!("Loaded {} patterns.", patterns.len());
Expand Down
11 changes: 0 additions & 11 deletions src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod units;
pub use command::{Command, CommandIterator};
pub use hash::CircuitHash;

use hugr::hugr::NodeType;
use hugr::HugrView;

pub use hugr::ops::OpType;
Expand Down Expand Up @@ -119,16 +118,6 @@ pub trait Circuit: HugrView {
// Traverse the circuit in topological order.
CommandIterator::new(self)
}

/// Returns the [`NodeType`] of a command.
fn command_nodetype(&self, command: &Command) -> &NodeType {
self.get_nodetype(command.node())
}

/// Returns the [`OpType`] of a command.
fn command_optype(&self, command: &Command) -> &OpType {
self.get_optype(command.node())
}
}

impl<T> Circuit for T where T: HugrView {}
Expand Down
Loading