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

chore(deps-rs): Update to hugr 0.9.0 #497

Merged
merged 1 commit into from
Jul 19, 2024
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
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ missing_docs = "warn"

[workspace.dependencies]

hugr = "0.8.0"
hugr-cli = "0.1.4"
hugr-core = "0.5.0"
hugr = "0.9.0"
hugr-cli = "0.2.0"
hugr-core = "0.6.0"
portgraph = "0.12"
pyo3 = "0.21.2"
itertools = "0.13.0"
Expand Down
2 changes: 1 addition & 1 deletion docs/quantum.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ compatibility:
1. The `main` function takes one `Array<N, Qubit>`
input and has one output of the same type (the same statically known
size).
2. All Operations that have a `FunctionType` involving `Qubit` have as
2. All Operations that have a `Signature` involving `Qubit` have as
many `Qubit` input wires as output.


Expand Down
12 changes: 5 additions & 7 deletions tket2-hseries/src/extension/futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ use hugr::{
ExtensionBuildError, ExtensionId, ExtensionRegistry, OpDef, SignatureFunc, TypeDef,
},
ops::{custom::ExtensionOp, CustomOp, OpType},
types::{
type_param::TypeParam, CustomType, FunctionType, PolyFuncType, Type, TypeArg, TypeBound,
},
types::{type_param::TypeParam, CustomType, PolyFuncType, Signature, Type, TypeArg, TypeBound},
Extension, Wire,
};
use lazy_static::lazy_static;
Expand Down Expand Up @@ -97,15 +95,15 @@ impl MakeOpDef for FutureOp {
let future_type = future_type(t_type.clone());
match self {
FutureOp::Read => {
PolyFuncType::new([t_param], FunctionType::new(future_type, t_type)).into()
PolyFuncType::new([t_param], Signature::new(future_type, t_type)).into()
}
FutureOp::Dup => PolyFuncType::new(
[t_param],
FunctionType::new(future_type.clone(), vec![future_type.clone(), future_type]),
Signature::new(future_type.clone(), vec![future_type.clone(), future_type]),
)
.into(),
FutureOp::Free => {
PolyFuncType::new([t_param], FunctionType::new(future_type.clone(), vec![])).into()
PolyFuncType::new([t_param], Signature::new(future_type.clone(), vec![])).into()
}
}
}
Expand Down Expand Up @@ -287,7 +285,7 @@ pub(crate) mod test {
let hugr = {
let mut func_builder = FunctionBuilder::new(
"circuit",
PolyFuncType::new(vec![t_param], FunctionType::new(future_type, t.clone())),
PolyFuncType::new(vec![t_param], Signature::new(future_type, t.clone())),
)
.unwrap();
let [future_w] = func_builder.input_wires_arr();
Expand Down
7 changes: 3 additions & 4 deletions tket2-hseries/src/extension/quantum_lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hugr::{
ExtensionId, ExtensionRegistry, OpDef, SignatureFunc, PRELUDE,
},
ops::{CustomOp, OpType},
types::FunctionType,
types::Signature,
Extension, Wire,
};

Expand Down Expand Up @@ -66,7 +66,7 @@ pub enum LazyQuantumOp {
impl MakeOpDef for LazyQuantumOp {
fn signature(&self) -> SignatureFunc {
match self {
Self::Measure => FunctionType::new(QB_T, vec![QB_T, future_type(BOOL_T)]).into(),
Self::Measure => Signature::new(QB_T, vec![QB_T, future_type(BOOL_T)]).into(),
}
}

Expand Down Expand Up @@ -147,8 +147,7 @@ mod test {
fn circuit() {
let hugr = {
let mut func_builder =
FunctionBuilder::new("circuit", FunctionType::new(QB_T, vec![QB_T, BOOL_T]))
.unwrap();
FunctionBuilder::new("circuit", Signature::new(QB_T, vec![QB_T, BOOL_T])).unwrap();
let [qb] = func_builder.input_wires_arr();
let [qb, lazy_b] = func_builder.add_lazy_measure(qb).unwrap();
let [b] = func_builder.add_read(lazy_b, BOOL_T).unwrap();
Expand Down
8 changes: 5 additions & 3 deletions tket2-hseries/src/extension/result.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! This module defines the Hugr extension used to represent result reporting operations,
//! with static string tags.
//!
use hugr::types::Signature;
use hugr::{
builder::{BuildError, Dataflow},
extension::{
Expand All @@ -21,7 +22,7 @@ use hugr::{
type_row,
types::{
type_param::{CustomTypeArg, TypeParam},
FunctionType, PolyFuncType, Type, TypeArg,
PolyFuncType, Type, TypeArg,
},
Extension, Wire,
};
Expand Down Expand Up @@ -175,7 +176,7 @@ impl ResultOpDef {

PolyFuncType::new(
[vec![string_param], self.type_params()].concat(),
FunctionType::new(self.arg_type(), type_row![]),
Signature::new(self.arg_type(), type_row![]),
)
.into()
}
Expand Down Expand Up @@ -412,6 +413,7 @@ impl<D: Dataflow> ResultOpBuilder for D {}
#[cfg(test)]
pub(crate) mod test {
use cool_asserts::assert_matches;
use hugr::types::Signature;
use hugr::{
builder::{Dataflow, DataflowHugr, FunctionBuilder},
extension::prelude::array_type,
Expand Down Expand Up @@ -455,7 +457,7 @@ pub(crate) mod test {
.concat();
let hugr = {
let mut func_builder =
FunctionBuilder::new("circuit", FunctionType::new(in_row, type_row![])).unwrap();
FunctionBuilder::new("circuit", Signature::new(in_row, type_row![])).unwrap();
let ops = [
ResultOp::new_bool("b"),
ResultOp::new_f64("f"),
Expand Down
12 changes: 6 additions & 6 deletions tket2-hseries/src/lazify_measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use hugr::{
ExtensionRegistry,
},
hugr::{hugrmut::HugrMut, views::SiblingSubgraph, Rewrite},
types::FunctionType,
types::Signature,
Hugr, HugrView, IncomingPort, Node, OutgoingPort, SimpleReplacement,
};
use tket2::Tk2Op;
Expand Down Expand Up @@ -85,7 +85,7 @@ impl State {

lazy_static! {
static ref MEASURE_READ_HUGR: Hugr = {
let mut builder = DFGBuilder::new(FunctionType::new(QB_T, vec![QB_T, BOOL_T])).unwrap();
let mut builder = DFGBuilder::new(Signature::new(QB_T, vec![QB_T, BOOL_T])).unwrap();
let [qb] = builder.input_wires_arr();
let [qb, lazy_r] = builder.add_lazy_measure(qb).unwrap();
let [r] = builder.add_read(lazy_r, BOOL_T).unwrap();
Expand All @@ -99,7 +99,7 @@ fn measure_replacement(num_dups: usize) -> Hugr {
let mut out_types = vec![QB_T];
out_types.extend((0..num_dups).map(|_| BOOL_T));
let num_out_types = out_types.len();
let mut builder = DFGBuilder::new(FunctionType::new(QB_T, out_types)).unwrap();
let mut builder = DFGBuilder::new(Signature::new(QB_T, out_types)).unwrap();
let [qb] = builder.input_wires_arr();
let [qb, mut future_r] = builder.add_lazy_measure(qb).unwrap();
let mut future_rs = vec![];
Expand Down Expand Up @@ -215,7 +215,7 @@ mod test {
#[test]
fn simple() {
let mut hugr = {
let mut builder = DFGBuilder::new(FunctionType::new(QB_T, vec![QB_T, BOOL_T])).unwrap();
let mut builder = DFGBuilder::new(Signature::new(QB_T, vec![QB_T, BOOL_T])).unwrap();
let [qb] = builder.input_wires_arr();
let outs = builder
.add_dataflow_op(Tk2Op::Measure, [qb])
Expand Down Expand Up @@ -248,7 +248,7 @@ mod test {
#[test]
fn multiple_uses() {
let mut builder =
DFGBuilder::new(FunctionType::new(QB_T, vec![QB_T, BOOL_T, BOOL_T])).unwrap();
DFGBuilder::new(Signature::new(QB_T, vec![QB_T, BOOL_T, BOOL_T])).unwrap();
let [qb] = builder.input_wires_arr();
let [qb, bool] = builder
.add_dataflow_op(Tk2Op::Measure, [qb])
Expand All @@ -267,7 +267,7 @@ mod test {

#[test]
fn no_uses() {
let mut builder = DFGBuilder::new(FunctionType::new_endo(QB_T)).unwrap();
let mut builder = DFGBuilder::new(Signature::new_endo(QB_T)).unwrap();
let [qb] = builder.input_wires_arr();
let [qb, _] = builder
.add_dataflow_op(Tk2Op::Measure, [qb])
Expand Down
2 changes: 1 addition & 1 deletion tket2-py/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use hugr::extension::prelude::{BOOL_T, QB_T};
use hugr::hugr::IdentList;
use hugr::ops::custom::{ExtensionOp, OpaqueOp};
use hugr::ops::{CustomOp, NamedOp, OpName, OpType};
use hugr::types::{CustomType, FunctionType, Type, TypeBound};
use hugr::types::{CustomType, Type, TypeBound};
use pyo3::prelude::*;
use std::fmt;

Expand Down
2 changes: 1 addition & 1 deletion tket2-py/src/circuit/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use hugr::builder::{CircuitBuilder, DFGBuilder, Dataflow, DataflowHugr};
use hugr::extension::prelude::QB_T;
use hugr::ops::handle::NodeHandle;
use hugr::ops::{CustomOp, OpType};
use hugr::types::{FunctionType, Type};
use hugr::types::Type;
use itertools::Itertools;
use pyo3::exceptions::{PyAttributeError, PyValueError};
use pyo3::types::{PyAnyMethods, PyModule, PyString, PyTypeMethods};
Expand Down
2 changes: 1 addition & 1 deletion tket2-py/src/circuit/tk2circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use hugr::builder::{CircuitBuilder, DFGBuilder, Dataflow, DataflowHugr};
use hugr::extension::prelude::QB_T;
use hugr::ops::handle::NodeHandle;
use hugr::ops::{CustomOp, OpType};
use hugr::types::{FunctionType, Type};
use hugr::types::Type;
use itertools::Itertools;
use pyo3::exceptions::{PyAttributeError, PyValueError};
use pyo3::types::{PyAnyMethods, PyModule, PyString, PyTypeMethods};
Expand Down
4 changes: 2 additions & 2 deletions tket2-py/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use derive_more::{From, Into};
use hugr::hugr::IdentList;
use hugr::ops::custom::{ExtensionOp, OpaqueOp};
use hugr::types::FunctionType;
use hugr::types::Signature;
use pyo3::prelude::*;
use std::fmt;
use std::str::FromStr;
Expand Down Expand Up @@ -252,7 +252,7 @@ impl PyCustomOp {
op_name,
Default::default(),
[],
FunctionType::new(into_vec(input_types), into_vec(output_types)),
Signature::new(into_vec(input_types), into_vec(output_types)),
))
.into())
}
Expand Down
4 changes: 2 additions & 2 deletions tket2/benches/benchmarks/generators.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use hugr::builder::{BuildError, CircuitBuilder, DFGBuilder, Dataflow, DataflowHugr};
use hugr::extension::prelude::QB_T;
use hugr::extension::PRELUDE_REGISTRY;
use hugr::types::FunctionType;
use hugr::types::Signature;
use hugr::Hugr;
use tket2::Tk2Op;

Expand All @@ -13,7 +13,7 @@ pub fn build_simple_circuit(
f: impl FnOnce(&mut CircuitBuilder<DFGBuilder<Hugr>>) -> Result<(), BuildError>,
) -> Result<Hugr, BuildError> {
let qb_row = vec![QB_T; num_qubits];
let mut h = DFGBuilder::new(FunctionType::new(qb_row.clone(), qb_row))?;
let mut h = DFGBuilder::new(Signature::new(qb_row.clone(), qb_row))?;

let qbs = h.input_wires();

Expand Down
12 changes: 6 additions & 6 deletions tket2/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use itertools::Either::{Left, Right};
use hugr::hugr::hugrmut::HugrMut;
use hugr::ops::dataflow::IOTrait;
use hugr::ops::{Input, NamedOp, OpParent, OpTag, OpTrait, Output};
use hugr::types::{FunctionType, PolyFuncType};
use hugr::types::{PolyFuncType, Signature};
use hugr::{Hugr, PortIndex};
use hugr::{HugrView, OutgoingPort};
use itertools::Itertools;
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<T: HugrView> Circuit<T> {

/// Returns the function type of the circuit.
#[inline]
pub fn circuit_signature(&self) -> FunctionType {
pub fn circuit_signature(&self) -> Signature {
let op = self.hugr.get_optype(self.parent);
op.inner_function_type()
.unwrap_or_else(|| panic!("{} is an invalid circuit parent type.", op.name()))
Expand Down Expand Up @@ -555,7 +555,7 @@ fn update_signature(
}
}
OpType::FuncDefn(defn) => {
let mut sig: FunctionType = defn.signature.clone().try_into().map_err(|_| {
let mut sig: Signature = defn.signature.clone().try_into().map_err(|_| {
CircuitError::ParametricSignature {
parent,
optype: OpType::FuncDefn(defn.clone()),
Expand All @@ -576,7 +576,7 @@ fn update_signature(
}
OpType::Case(case) => {
let out_types = out_types.unwrap_or_else(|| case.signature.output().clone());
case.signature = FunctionType::new(inp_types, out_types)
case.signature = Signature::new(inp_types, out_types)
}
OpType::TailLoop(_) => {
unimplemented!("TailLoop signature update")
Expand All @@ -597,7 +597,7 @@ mod tests {
use cool_asserts::assert_matches;
use rstest::{fixture, rstest};

use hugr::types::FunctionType;
use hugr::types::Signature;
use hugr::{
builder::{DFGBuilder, DataflowHugr},
extension::{prelude::BOOL_T, PRELUDE_REGISTRY},
Expand Down Expand Up @@ -713,7 +713,7 @@ mod tests {

#[test]
fn remove_bit() {
let h = DFGBuilder::new(FunctionType::new(vec![BOOL_T], vec![])).unwrap();
let h = DFGBuilder::new(Signature::new(vec![BOOL_T], vec![])).unwrap();
let mut circ: Circuit = h
.finish_hugr_with_outputs([], &PRELUDE_REGISTRY)
.unwrap()
Expand Down
8 changes: 4 additions & 4 deletions tket2/src/circuit/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ mod test {
use hugr::ops::{NamedOp, Value};
use hugr::std_extensions::arithmetic::float_ops::FLOAT_OPS_REGISTRY;
use hugr::std_extensions::arithmetic::float_types::ConstF64;
use hugr::types::FunctionType;
use hugr::types::Signature;
use itertools::Itertools;
use rstest::{fixture, rstest};
use std::collections::hash_map::DefaultHasher;
Expand Down Expand Up @@ -588,7 +588,7 @@ mod test {
#[test]
fn commands_nonlinear() {
let qb_row = vec![QB_T; 1];
let mut h = DFGBuilder::new(FunctionType::new(qb_row.clone(), qb_row)).unwrap();
let mut h = DFGBuilder::new(Signature::new(qb_row.clone(), qb_row)).unwrap();
let [q_in] = h.input_wires_arr();

let constant = h.add_constant(Value::extension(ConstF64::new(0.5)));
Expand Down Expand Up @@ -659,7 +659,7 @@ mod test {
#[test]
fn alloc_free() -> Result<(), Box<dyn std::error::Error>> {
let qb_row = vec![QB_T; 1];
let mut h = DFGBuilder::new(FunctionType::new(qb_row.clone(), qb_row))?;
let mut h = DFGBuilder::new(Signature::new(qb_row.clone(), qb_row))?;

let [q_in] = h.input_wires_arr();

Expand Down Expand Up @@ -715,7 +715,7 @@ mod test {
#[test]
fn test_impls() -> Result<(), Box<dyn std::error::Error>> {
let qb_row = vec![QB_T; 1];
let mut h = DFGBuilder::new(FunctionType::new(qb_row.clone(), vec![]))?;
let mut h = DFGBuilder::new(Signature::new(qb_row.clone(), vec![]))?;
let [q_in] = h.input_wires_arr();
h.add_dataflow_op(Tk2Op::QFree, [q_in])?;
let circ: Circuit = h.finish_hugr_with_outputs([], &REGISTRY)?.into();
Expand Down
Loading
Loading