Skip to content

Commit 8ccb500

Browse files
mergify[bot]raynelfssjakelishman
authored
Represent non-fixed params as NaN for QkTargetOp (#15463) (#15525)
* Initial: Represent non-fixed params as `NaN` * Docs: Add release note * Docs: Removed incorrect wording in release note. --------- (cherry picked from commit 2e3eeb3) Co-authored-by: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com> Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
1 parent bdef7b9 commit 8ccb500

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

crates/cext/src/transpiler/target.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,8 +1343,9 @@ pub struct CTargetOp {
13431343
/// `(uint32_t)-1` in the case of a variadic.
13441344
pub num_qubits: u32,
13451345
/// The parameters tied to this operation if fixed, as an array
1346-
/// of `double`. If the operation doesn't posess any fixed parameters
1347-
/// or is variadic, this attribute will be a ``NULL`` pointer.
1346+
/// of `double`. If any of the parameters represented are not fixed angles
1347+
/// it will be represented as with the `NaN` value. If there are no parameters
1348+
/// then this value will be represented with a `NULL` pointer.
13481349
pub params: *mut f64,
13491350
/// The number of parameters supported by this operation. Will default to
13501351
/// `(uint32_t)-1` in the case of a variadic.
@@ -1426,9 +1427,9 @@ pub unsafe extern "C" fn qk_target_op_get(
14261427
operation
14271428
.params_view()
14281429
.iter()
1429-
.filter_map(|param| match param {
1430-
Param::Float(number) => Some(*number),
1431-
_ => None,
1430+
.map(|param| match param {
1431+
Param::Float(number) => *number,
1432+
_ => f64::NAN,
14321433
})
14331434
.collect(),
14341435
);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
fixes:
3+
- |
4+
Fixed a mismatch in :c:struct:`QkTargetOp` in which the length of the array
5+
stored in :c:member:`QkTargetOp.params` did not match the number exposed by
6+
:c:member:`QkTargetOp.num_params`. Wildcard parameters are now represented
7+
by ``NAN``, and the length of the array will always be :c:member:`QkTargetOp.num_params`.
8+
This bug was only present in 2.3.0rc1.

0 commit comments

Comments
 (0)