Skip to content

Commit

Permalink
check quantum extension name is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Aug 24, 2023
1 parent e753079 commit a70bbc3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/json/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//! circuits by ensuring they always define a signature, and computing the
//! explicit count of qubits and linear bits.

use hugr::extension::ExtensionSet;
use hugr::extension::prelude::QB_T;
use hugr::extension::ExtensionSet;
use hugr::ops::custom::ExternalOp;
use hugr::ops::{LeafOp, OpTrait, OpType};
use hugr::std_extensions::arithmetic::float_types::FLOAT64_TYPE;
Expand Down Expand Up @@ -230,11 +230,13 @@ impl TryFrom<&OpType> for JsonOp {
let json_optype: JsonOpType = match op {
OpType::LeafOp(LeafOp::Noop { .. }) => JsonOpType::noop,
OpType::LeafOp(LeafOp::CustomOp(b)) => match (*b).as_ref() {
ExternalOp::Extension(c) => match &c.def().name()[..] {
"H" => JsonOpType::H,
"CX" => JsonOpType::CX,
_ => return Err(err()),
},
ExternalOp::Extension(c) if c.def().extension() == "quantum" => {
match &c.def().name()[..] {
"H" => JsonOpType::H,
"CX" => JsonOpType::CX,
_ => return Err(err()),
}
}
_ => return Err(err()),
// h_gate() => JsonOpType::H,
// cx_gate() => JsonOpType::CX,
Expand Down

0 comments on commit a70bbc3

Please sign in to comment.