From 09ab3a2c9c6758b06701e3b63425e163bd850eeb Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Tue, 20 Feb 2024 15:12:47 +0000 Subject: [PATCH] chore: update to hugr 0.2 (#292) - CustomConst changed - update strum --- Cargo.toml | 2 +- tket2/Cargo.toml | 2 +- tket2/src/extension/angle.rs | 28 ++++++++++++---------------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f8fcdf12..1adad676 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ missing_docs = "warn" [workspace.dependencies] tket2 = { path = "./tket2" } -quantinuum-hugr = { version = "0.1" } +quantinuum-hugr = { version = "0.2" } portgraph = { version = "0.11" } pyo3 = { version = "0.20" } itertools = { version = "0.12.0" } diff --git a/tket2/Cargo.toml b/tket2/Cargo.toml index 97b7c16a..93a20f70 100644 --- a/tket2/Cargo.toml +++ b/tket2/Cargo.toml @@ -49,7 +49,7 @@ quantinuum-hugr = { workspace = true } portgraph = { workspace = true, features = ["serde"] } pyo3 = { workspace = true, optional = true, features = ["multiple-pymethods"] } strum_macros = "0.26.1" -strum = "0.25.0" +strum = "0.26.1" fxhash = "0.2.1" rmp-serde = { version = "1.1.2", optional = true } delegate = "0.12.0" diff --git a/tket2/src/extension/angle.rs b/tket2/src/extension/angle.rs index 3ed48b30..2f56cf0b 100644 --- a/tket2/src/extension/angle.rs +++ b/tket2/src/extension/angle.rs @@ -5,8 +5,7 @@ use hugr::{ extension::{prelude::ERROR_TYPE, SignatureError, SignatureFromArgs, TypeDef}, types::{ type_param::{TypeArgError, TypeParam}, - ConstTypeError, CustomCheckFailure, CustomType, FunctionType, PolyFuncType, Type, TypeArg, - TypeBound, + ConstTypeError, CustomType, FunctionType, PolyFuncType, Type, TypeArg, TypeBound, }, values::CustomConst, Extension, @@ -116,14 +115,9 @@ impl CustomConst for ConstAngle { fn name(&self) -> SmolStr { format!("a(2π*{}/2^{})", self.value, self.log_denom).into() } - fn check_custom_type(&self, typ: &CustomType) -> Result<(), CustomCheckFailure> { - if typ.clone() == super::angle_custom_type(self.log_denom) { - Ok(()) - } else { - Err(CustomCheckFailure::Message( - "Angle constant type mismatch.".into(), - )) - } + + fn custom_type(&self) -> CustomType { + super::angle_custom_type(self.log_denom) } fn equal_consts(&self, other: &dyn CustomConst) -> bool { hugr::values::downcast_equal_consts(self, other) @@ -270,12 +264,14 @@ mod test { assert_ne!(const_a32_7, const_a32_8); assert_eq!(const_a32_7, ConstAngle::new(5, 7).unwrap()); - assert!(const_a32_7 - .check_custom_type(&super::super::angle_custom_type(5)) - .is_ok()); - assert!(const_a32_7 - .check_custom_type(&super::super::angle_custom_type(6)) - .is_err()); + assert_eq!( + const_a32_7.custom_type(), + super::super::angle_custom_type(5) + ); + assert_ne!( + const_a32_7.custom_type(), + super::super::angle_custom_type(6) + ); assert!(matches!( ConstAngle::new(3, 256), Err(ConstTypeError::CustomCheckFail(_))