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

feat!: Support old Composite alias for CustomGate #91

Merged
merged 1 commit into from
Nov 13, 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
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")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be CompositeGate?

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")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be CompositeGate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optype enum said Composite, but the class was CompositeGate.
https://github.com/CQCL/tket/pull/175/files#diff-76f05b37a15248c7c6dd673f19dc5b8e74829d4d2ae0ad1316c982ab7fd3373fL567-L570
Do you know which one should it be?

I don't have an old json to verify (@johnchildren do you?).
I could also just add both alias.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it was ever called CompositeGate, but I'd have to look through the tket commit history too check. I think it was called Composite with a class of CompositeGate but was then renamed to CustomGate (both op type and class) later from memory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry yeah see the PR from the issue: https://github.com/CQCL/tket/pull/175/files

It was called Composite and was never called CompositeGate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, looks like it should match the OpType rather than the class, so Composite is correct.

CustomGate,

/// See [`QControlBox`]
Expand Down
Loading