Skip to content

Commit 5988450

Browse files
doichanjCryoris
andauthored
Add QkParam to the C API (#14837)
* Add C-API for ParameterExpression * add test cases for Parameter C-API * rename qk_paramter_ to qk_param_, fix array format of bind/subs functions * fix test for param * use existing QkParam to save results of operations * fix test_param.c * fix test_param.c * fix for lint, add releasenote * Update crates/cext/src/param.rs Co-authored-by: Julien Gacon <[email protected]> * Update crates/cext/src/param.rs Co-authored-by: Julien Gacon <[email protected]> * Update crates/cext/src/param.rs Co-authored-by: Julien Gacon <[email protected]> * Update crates/cext/src/param.rs Co-authored-by: Julien Gacon <[email protected]> * Update crates/cext/src/param.rs Co-authored-by: Julien Gacon <[email protected]> * Update crates/cext/src/param.rs Co-authored-by: Julien Gacon <[email protected]> * Update crates/cext/src/param.rs Co-authored-by: Julien Gacon <[email protected]> * add qk_param_zero(), rename qk_param_new to qk_param_new_symbol * remove unsafe from qk_param_zero * rename ``qk_param_str`` for consistency compare to ``qk_obs_str`` * Cleanup tests - use goto for shorter code - handle QkExitCode from arithmetic functions - add docstrings * Doc chores - proper code highlighting - fix C code sections - fix safety sections - update exit code docs * Docs & small improvements for bind/subs * More tests * Update reno * Jake's review comments - light edition the others are for follow ups :) * drop bind/subs for now there are open discussions on what the right interface to reduce the allocations in practice. Let's unblock parameters while we have this discussion * one more go at safer print * update reno * fix test artifact * fix rust edition 2024 * don't use VLA (thanks MSVC) * rm string prints * rm ctype --------- Co-authored-by: Julien Gacon <[email protected]> Co-authored-by: Julien Gacon <[email protected]>
1 parent cde5f55 commit 5988450

File tree

7 files changed

+1634
-0
lines changed

7 files changed

+1634
-0
lines changed

crates/cext/cbindgen.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ prefix_with_name = true
8585
"TranspileLayout" = "QkTranspileLayout"
8686
"TranspileResult" = "QkTranspileResult"
8787
"TranspileOptions" = "QkTranspileOptions"
88+
"Param" = "QkParam"

crates/cext/src/exit_codes.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// copyright notice, and modified files need to carry a notice indicating
1111
// that they have been altered from the originals.
1212

13+
use qiskit_circuit::parameter::parameter_expression::ParameterError;
1314
use qiskit_quantum_info::sparse_observable::ArithmeticError;
1415
use qiskit_transpiler::target::TargetError;
1516
use thiserror::Error;
@@ -96,3 +97,9 @@ impl From<TargetError> for ExitCode {
9697
}
9798
}
9899
}
100+
101+
impl From<ParameterError> for ExitCode {
102+
fn from(_value: ParameterError) -> Self {
103+
ExitCode::ArithmeticError
104+
}
105+
}

crates/cext/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ mod pointers;
1414

1515
pub mod circuit;
1616
pub mod exit_codes;
17+
pub mod param;
1718
pub mod sparse_observable;
1819
pub mod transpiler;

0 commit comments

Comments
 (0)