forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into move-equivalence
- Loading branch information
Showing
32 changed files
with
2,501 additions
and
735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ pull_request_rules: | |
actions: | ||
backport: | ||
branches: | ||
- stable/1.1 | ||
- stable/1.2 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// This code is part of Qiskit. | ||
// | ||
// (C) Copyright IBM 2024 | ||
// | ||
// This code is licensed under the Apache License, Version 2.0. You may | ||
// obtain a copy of this license in the LICENSE.txt file in the root directory | ||
// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Any modifications or derivative works of this code must retain this | ||
// copyright notice, and modified files need to carry a notice indicating | ||
// that they have been altered from the originals. | ||
|
||
use std::{error::Error, fmt::Display}; | ||
|
||
/// Error thrown when operation key is not present in the Target | ||
#[derive(Debug)] | ||
pub struct TargetKeyError { | ||
pub message: String, | ||
} | ||
|
||
impl TargetKeyError { | ||
/// Initializes the new error | ||
pub fn new_err(message: String) -> Self { | ||
Self { message } | ||
} | ||
} | ||
|
||
impl Display for TargetKeyError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", self.message) | ||
} | ||
} | ||
|
||
impl Error for TargetKeyError {} |
72 changes: 72 additions & 0 deletions
72
crates/accelerate/src/target_transpiler/instruction_properties.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// This code is part of Qiskit. | ||
// | ||
// (C) Copyright IBM 2024 | ||
// | ||
// This code is licensed under the Apache License, Version 2.0. You may | ||
// obtain a copy of this license in the LICENSE.txt file in the root directory | ||
// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Any modifications or derivative works of this code must retain this | ||
// copyright notice, and modified files need to carry a notice indicating | ||
// that they have been altered from the originals. | ||
|
||
use pyo3::{prelude::*, pyclass}; | ||
|
||
/** | ||
A representation of an ``InstructionProperties`` object. | ||
*/ | ||
#[pyclass( | ||
subclass, | ||
name = "BaseInstructionProperties", | ||
module = "qiskit._accelerate.target" | ||
)] | ||
#[derive(Clone, Debug)] | ||
pub struct InstructionProperties { | ||
#[pyo3(get, set)] | ||
pub duration: Option<f64>, | ||
#[pyo3(get, set)] | ||
pub error: Option<f64>, | ||
} | ||
|
||
#[pymethods] | ||
impl InstructionProperties { | ||
/// Create a new ``BaseInstructionProperties`` object | ||
/// | ||
/// Args: | ||
/// duration (Option<f64>): The duration, in seconds, of the instruction on the | ||
/// specified set of qubits | ||
/// error (Option<f64>): The average error rate for the instruction on the specified | ||
/// set of qubits. | ||
/// calibration (Option<PyObject>): The pulse representation of the instruction. | ||
#[new] | ||
#[pyo3(signature = (duration=None, error=None))] | ||
pub fn new(_py: Python<'_>, duration: Option<f64>, error: Option<f64>) -> Self { | ||
Self { error, duration } | ||
} | ||
|
||
fn __getstate__(&self) -> PyResult<(Option<f64>, Option<f64>)> { | ||
Ok((self.duration, self.error)) | ||
} | ||
|
||
fn __setstate__(&mut self, _py: Python<'_>, state: (Option<f64>, Option<f64>)) -> PyResult<()> { | ||
self.duration = state.0; | ||
self.error = state.1; | ||
Ok(()) | ||
} | ||
|
||
fn __repr__(&self, _py: Python<'_>) -> String { | ||
format!( | ||
"InstructionProperties(duration={}, error={})", | ||
if let Some(duration) = self.duration { | ||
duration.to_string() | ||
} else { | ||
"None".to_string() | ||
}, | ||
if let Some(error) = self.error { | ||
error.to_string() | ||
} else { | ||
"None".to_string() | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.