From 4062cccd599ca8d9176c61cb188b22656ee824bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= Date: Wed, 13 Nov 2024 12:33:34 +0000 Subject: [PATCH] feat!: Support old `Composite` alias for `CustomGate` --- src/circuit_json.rs | 4 +++- src/opbox.rs | 5 +++-- src/optype.rs | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/circuit_json.rs b/src/circuit_json.rs index 7942c6d..d28359b 100644 --- a/src/circuit_json.rs +++ b/src/circuit_json.rs @@ -9,8 +9,10 @@ use crate::register::{Bit, BitRegister, ElementId, Qubit}; use serde::{Deserialize, Serialize}; /// A gate defined by a circuit. +/// +/// Previously known as `CompositeGate`. #[derive(Deserialize, Serialize, Clone, Debug, PartialEq)] -pub struct CompositeGate { +pub struct CustomGate { /// Name of the composite gate. pub name: String, /// Expressions corresponding to parameter values of the composite gate, if it has parameters. diff --git a/src/opbox.rs b/src/opbox.rs index 6b00479..76ccb88 100644 --- a/src/opbox.rs +++ b/src/opbox.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use crate::circuit_json::{ - ClassicalExp, CompositeGate, Matrix, Operation, Permutation, SerialCircuit, + ClassicalExp, CustomGate, Matrix, Operation, Permutation, SerialCircuit, }; use crate::optype::OpType; use crate::register::{Bitstring, Qubit}; @@ -129,10 +129,11 @@ pub enum OpBox { /// A user-defined assertion specified by a 2x2, 4x4, or 8x8 projector matrix. ProjectorAssertionBox { id: BoxID, matrix: Matrix }, /// A user-defined gate defined by a parametrised Circuit. + #[serde(alias = "Composite")] CustomGate { id: BoxID, /// The gate defined as a circuit. - gate: CompositeGate, + gate: CustomGate, // Vec of Symengine Expr params: Vec, }, diff --git a/src/optype.rs b/src/optype.rs index ed5577e..281f18c 100644 --- a/src/optype.rs +++ b/src/optype.rs @@ -486,6 +486,7 @@ pub enum OpType { /// See [`CustomGate`] /// /// [`CustomGate`]: crate::opbox::OpBox::CustomGate + #[serde(alias = "Composite")] CustomGate, /// See [`QControlBox`]