Skip to content

Commit

Permalink
feat!: Support old Composite alias for CustomGate (#91)
Browse files Browse the repository at this point in the history
Closes #67 

BREAKING CHANGE: Renamed `circuit_json::CompositeGate` to `CustomGate`
  • Loading branch information
aborgna-q authored Nov 13, 2024
1 parent 1499fee commit dbf513d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/circuit_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions src/opbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<String>,
},
Expand Down
1 change: 1 addition & 0 deletions src/optype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ pub enum OpType {
/// See [`CustomGate`]
///
/// [`CustomGate`]: crate::opbox::OpBox::CustomGate
#[serde(alias = "Composite")]
CustomGate,

/// See [`QControlBox`]
Expand Down

0 comments on commit dbf513d

Please sign in to comment.