Skip to content

Commit

Permalink
chore: update to hugr 0.2 (#292)
Browse files Browse the repository at this point in the history
- CustomConst changed
- update strum
  • Loading branch information
ss2165 authored Feb 20, 2024
1 parent 8a0bedf commit 09ab3a2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion tket2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
28 changes: 12 additions & 16 deletions tket2/src/extension/angle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(_))
Expand Down

0 comments on commit 09ab3a2

Please sign in to comment.