From 409b82633fc697ee95910c4963ba8cbf3bfe94a0 Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Tue, 26 Nov 2024 17:09:13 +0000 Subject: [PATCH] rename more things --- tket2-hseries/src/extension/qsystem.rs | 2 +- tket2-hseries/src/extension/qsystem/lower.rs | 14 ++++---- tket2-hseries/src/lib.rs | 34 ++++++++++---------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tket2-hseries/src/extension/qsystem.rs b/tket2-hseries/src/extension/qsystem.rs index daaf2105..1c2df920 100644 --- a/tket2-hseries/src/extension/qsystem.rs +++ b/tket2-hseries/src/extension/qsystem.rs @@ -32,7 +32,7 @@ use super::futures::future_type; mod lower; use lower::pi_mul_f64; -pub use lower::{check_lowered, lower_tk2_op, LowerTk2Error, LowerTket2ToHSeriesPass}; +pub use lower::{check_lowered, lower_tk2_op, LowerTk2Error, LowerTket2ToQSystemPass}; /// The "tket2.qsystem" extension id. pub const EXTENSION_ID: ExtensionId = ExtensionId::new_unchecked("tket2.qsystem"); diff --git a/tket2-hseries/src/extension/qsystem/lower.rs b/tket2-hseries/src/extension/qsystem/lower.rs index 7bdde414..452fcfa3 100644 --- a/tket2-hseries/src/extension/qsystem/lower.rs +++ b/tket2-hseries/src/extension/qsystem/lower.rs @@ -176,10 +176,10 @@ pub fn check_lowered(hugr: &impl HugrView) -> Result<(), Vec> { /// Invokes [lower_tk2_op]. If validation is enabled the resulting HUGR is /// checked with [check_lowered]. #[derive(Default, Debug, Clone)] -pub struct LowerTket2ToHSeriesPass(ValidationLevel); +pub struct LowerTket2ToQSystemPass(ValidationLevel); -impl LowerTket2ToHSeriesPass { - /// Run `LowerTket2ToHSeriesPass` on the given [HugrMut]. `registry` is used +impl LowerTket2ToQSystemPass { + /// Run `LowerTket2ToQSystemPass` on the given [HugrMut]. `registry` is used /// for validation, if enabled. pub fn run( &self, @@ -196,7 +196,7 @@ impl LowerTket2ToHSeriesPass { }) } - /// Returns a new `LowerTket2ToHSeriesPass` with the given [ValidationLevel]. + /// Returns a new `LowerTket2ToQSystemPass` with the given [ValidationLevel]. pub fn with_validation_level(&self, level: ValidationLevel) -> Self { Self(level) } @@ -283,7 +283,7 @@ mod test { // conditional doesn't fit in to commands #[case(Tk2Op::Measure, None)] #[case(Tk2Op::QAlloc, None)] - fn test_lower(#[case] t2op: Tk2Op, #[case] hseries_ops: Option>) { + fn test_lower(#[case] t2op: Tk2Op, #[case] qsystem_ops: Option>) { // build dfg with just the op let h = op_to_hugr(t2op).unwrap(); @@ -292,8 +292,8 @@ mod test { .commands() .filter_map(|com| com.optype().cast()) .collect(); - if let Some(hseries_ops) = hseries_ops { - assert_eq!(ops, hseries_ops); + if let Some(qsystem_ops) = qsystem_ops { + assert_eq!(ops, qsystem_ops); } assert_eq!(check_lowered(&h), Ok(())); diff --git a/tket2-hseries/src/lib.rs b/tket2-hseries/src/lib.rs index ddeb2a72..2079204c 100644 --- a/tket2-hseries/src/lib.rs +++ b/tket2-hseries/src/lib.rs @@ -13,7 +13,7 @@ use tket2::Tk2Op; use extension::{ futures::FutureOpDef, - qsystem::{LowerTk2Error, LowerTket2ToHSeriesPass, QSystemOp}, + qsystem::{LowerTk2Error, LowerTket2ToQSystemPass, QSystemOp}, }; use lazify_measure::{LazifyMeasurePass, LazifyMeasurePassError}; @@ -23,37 +23,37 @@ pub mod extension; pub mod lazify_measure; -/// Modify a [hugr::Hugr] into a form that is acceptable for ingress into an H-series. +/// Modify a [hugr::Hugr] into a form that is acceptable for ingress into a Q-System. /// Returns an error if this cannot be done. /// -/// To construct a `HSeriesPass` use [Default::default]. +/// To construct a `QSystemPass` use [Default::default]. #[derive(Debug, Clone, Copy, Default)] -pub struct HSeriesPass { +pub struct QSystemPass { validation_level: ValidationLevel, } #[derive(Error, Debug, Display, From)] #[non_exhaustive] -/// An error reported from [HSeriesPass]. -pub enum HSeriesPassError { +/// An error reported from [QSystemPass]. +pub enum QSystemPassError { /// The [hugr::Hugr] was invalid either before or after a pass ran. ValidationError(ValidatePassError), /// An error from the component [LazifyMeasurePass]. LazyMeasureError(LazifyMeasurePassError), /// An error from the component [force_order()] pass. ForceOrderError(HugrError), - /// An error from the component [LowerTket2ToHSeriesPass] pass. + /// An error from the component [LowerTket2ToQSystemPass] pass. LowerTk2Error(LowerTk2Error), } -impl HSeriesPass { - /// Run `HSeriesPass` on the given [HugrMut]. `registry` is used for +impl QSystemPass { + /// Run `QSystemPass` on the given [HugrMut]. `registry` is used for /// validation, if enabled. pub fn run( &self, hugr: &mut impl HugrMut, registry: &ExtensionRegistry, - ) -> Result<(), HSeriesPassError> { + ) -> Result<(), QSystemPassError> { self.lower_tk2().run(hugr, registry)?; self.lazify_measure().run(hugr, registry)?; self.validation_level @@ -70,20 +70,20 @@ impl HSeriesPass { 0 } })?; - Ok::<_, HSeriesPassError>(()) + Ok::<_, QSystemPassError>(()) })?; Ok(()) } - fn lower_tk2(&self) -> LowerTket2ToHSeriesPass { - LowerTket2ToHSeriesPass::default().with_validation_level(self.validation_level) + fn lower_tk2(&self) -> LowerTket2ToQSystemPass { + LowerTket2ToQSystemPass::default().with_validation_level(self.validation_level) } fn lazify_measure(&self) -> LazifyMeasurePass { LazifyMeasurePass::default().with_validation_level(self.validation_level) } - /// Returns a new `HSeriesPass` with the given [ValidationLevel]. + /// Returns a new `QSystemPass` with the given [ValidationLevel]. pub fn with_validation_level(mut self, level: ValidationLevel) -> Self { self.validation_level = level; self @@ -106,11 +106,11 @@ mod test { use crate::{ extension::{futures::FutureOpDef, qsystem::QSystemOp}, - HSeriesPass, + QSystemPass, }; #[test] - fn hseries_pass() { + fn qsystem_pass() { let registry = &tket2::extension::REGISTRY; let (mut hugr, [call_node, h_node, f_node, rx_node]) = { let mut builder = DFGBuilder::new(Signature::new(QB_T, vec![BOOL_T, BOOL_T])).unwrap(); @@ -160,7 +160,7 @@ mod test { (hugr, [call_node, h_node, f_node, rx_node]) }; - HSeriesPass::default().run(&mut hugr, registry).unwrap(); + QSystemPass::default().run(&mut hugr, registry).unwrap(); let topo_sorted = Topo::new(&hugr.as_petgraph()) .iter(&hugr.as_petgraph())