Skip to content
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
4 changes: 1 addition & 3 deletions tket/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,16 @@

// Public API exports
pub use flow::{DefaultResourceFlow, ResourceFlow, UnsupportedOp};
pub use interval::Interval;
pub use scope::{ResourceScope, ResourceScopeConfig};
pub use types::{CircuitUnit, Position, ResourceAllocator, ResourceId};

// Internal modules
mod flow;
mod interval;
mod scope;
mod types;

#[cfg(test)]
mod tests {
pub(crate) mod tests {
use hugr::{
builder::{DFGBuilder, Dataflow, DataflowHugr},
extension::prelude::qb_t,
Expand Down
340 changes: 0 additions & 340 deletions tket/src/resource/interval.rs

This file was deleted.

20 changes: 20 additions & 0 deletions tket/src/resource/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ impl<H: HugrView> ResourceScope<H> {
Some(*port_map.get(port))
}

/// Get the [`ResourceId`] for a given port.
///
/// Return None if the port is not a resource port.
pub fn get_resource_id(&self, node: H::Node, port: impl Into<Port>) -> Option<ResourceId> {
let unit = self.get_circuit_unit(node, port)?;
unit.as_resource()
}

/// Get all [`CircuitUnit`]s for either the incoming or outgoing ports of a
/// node.
pub fn get_circuit_units_slice(
Expand Down Expand Up @@ -626,6 +634,18 @@ pub(crate) mod tests {

pub type PathEl<N> = (Position, N, Port);

impl<H: HugrView> ResourceScope<H> {
/// A test helper to create scopes with modified positions.
///
/// The transformation must preserve the order of positions, i.e. if
/// pos[n] < pos[m], then map_pos(pos[n]) < map_pos(pos[m]).
pub(crate) fn map_positions(&mut self, map_pos: impl Fn(Position) -> Position) {
for node_units in self.circuit_units.values_mut() {
node_units.position = map_pos(node_units.position);
}
}
}

/// Statistics about a ResourceScope.
#[derive(Debug, Clone)]
pub struct ResourceScopeReport<H: HugrView> {
Expand Down
Loading
Loading