From bd5fcc4323138ca39e365ba3fe66d6f4efb936e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= <121866228+aborgna-q@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:32:17 +0000 Subject: [PATCH] feat!: `created/discarded_qubits` circuit attribute (#87) [pytket `1.7.3`](https://tket.quantinuum.com/api-docs/changelog.html#october-2022) added `created`/`discarded_qubits` fields to the circuit serialization, but we never added them here. BREAKING CHANGE: Made `SerialCircuit` non exhaustive. --- src/circuit_json.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/circuit_json.rs b/src/circuit_json.rs index c4d34b2..d442abc 100644 --- a/src/circuit_json.rs +++ b/src/circuit_json.rs @@ -206,6 +206,7 @@ pub struct ImplicitPermutation(pub Register, pub Register); /// Pytket canonical serialized circuit #[derive(Deserialize, Serialize, Clone, Debug, PartialEq)] +#[non_exhaustive] pub struct SerialCircuit
{ /// The name of the circuit. #[serde(skip_serializing_if = "Option::is_none")] @@ -223,6 +224,12 @@ pub struct SerialCircuit
{
/// Number of wasm wires in the circuit.
#[serde(skip_serializing_if = "Option::is_none")]
pub number_of_ws: Option Default for Operation {
@@ -241,6 +248,22 @@ impl Default for Operation {
}
}
+impl {
+ fn default() -> Self {
+ Self {
+ name: None,
+ phase: Default::default(),
+ commands: Default::default(),
+ qubits: Default::default(),
+ bits: Default::default(),
+ implicit_permutation: Default::default(),
+ number_of_ws: None,
+ created_qubits: None,
+ discarded_qubits: None,
+ }
+ }
+}
+
impl Operation {
/// Returns a default-initialized Operation with the given type.
///
@@ -289,6 +312,21 @@ impl Command {
}
impl SerialCircuit {
+ /// Initialize a new SerialCircuit with the given name and phase.
+ pub fn new(name: Option SerialCircuit {
bits: self.bits,
implicit_permutation: self.implicit_permutation,
number_of_ws: self.number_of_ws,
+ created_qubits: self.created_qubits,
+ discarded_qubits: self.discarded_qubits,
}
}
}