• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / qiskit / 23548889554

25 Mar 2026 03:22PM UTC coverage: 87.191% (-0.04%) from 87.235%
23548889554

Pull #15836

github

web-flow
Merge 4df6d9082 into 3e8032600
Pull Request #15836: Use `np.bitwise_count` in `BitArray.bitcount`

1 of 5 new or added lines in 1 file covered. (20.0%)

1085 existing lines in 41 files now uncovered.

103626 of 118850 relevant lines covered (87.19%)

1001189.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.0
/crates/cext/src/exit_codes.rs
1
// This code is part of Qiskit.
2
//
3
// (C) Copyright IBM 2024
4
//
5
// This code is licensed under the Apache License, Version 2.0. You may
6
// obtain a copy of this license in the LICENSE.txt file in the root directory
7
// of this source tree or at https://www.apache.org/licenses/LICENSE-2.0.
8
//
9
// Any modifications or derivative works of this code must retain this
10
// copyright notice, and modified files need to carry a notice indicating
11
// that they have been altered from the originals.
12

13
use qiskit_circuit::parameter::parameter_expression::ParameterError;
14
use qiskit_quantum_info::sparse_observable::ArithmeticError;
15
use qiskit_transpiler::target::TargetError;
16
use thiserror::Error;
17

18
/// Errors related to C input.
19
#[derive(Error, Debug)]
20
pub enum CInputError {
21
    #[error("Unexpected null pointer.")]
22
    NullPointerError,
23
    #[error("Non-aligned memory.")]
24
    AlignmentError,
25
    #[error("Index out of bounds.")]
26
    IndexError,
27
}
28

29
/// Integer exit codes returned to C.
30
#[repr(u32)]
31
#[derive(PartialEq, Eq, Debug)]
32
pub enum ExitCode {
33
    /// Success.
34
    Success = 0,
35
    /// Error related to data input.
36
    CInputError = 100,
37
    /// Unexpected null pointer.
38
    NullPointerError = 101,
39
    /// Pointer is not aligned to expected data.
40
    AlignmentError = 102,
41
    /// Index out of bounds.
42
    IndexError = 103,
43
    /// Duplicate index.
44
    DuplicateIndexError = 104,
45
    /// Invalid ``QkOperationKind``.
46
    InvalidOperationKind = 105,
47
    /// Error related to arithmetic operations or similar.
48
    ArithmeticError = 200,
49
    /// Mismatching number of qubits.
50
    MismatchedQubits = 201,
51
    /// Matrix is not unitary.
52
    ExpectedUnitary = 202,
53
    /// Target related error
54
    TargetError = 300,
55
    /// Instruction already exists in the Target
56
    TargetInstAlreadyExists = 301,
57
    /// Properties with incorrect qargs was added
58
    TargetQargMismatch = 302,
59
    /// Trying to query into the target with non-existent qargs.
60
    TargetInvalidQargsKey = 303,
61
    /// Querying an operation that doesn't exist in the Target.
62
    TargetInvalidInstKey = 304,
63
    /// Transpilation failed
64
    TranspilerError = 400,
65
    /// QkDag operation error
66
    DagError = 500,
67
    /// The DAGs have mismatching qubit/clbit amounts during compose.
68
    DagComposeMismatch = 501,
69
    /// One or more bit indices were not found during compose.
70
    DagComposeMissingBit = 502,
71
    /// Errors concerning parameter handling.
72
    ParameterError = 600,
73
    /// Parameter name conflict.
74
    ParameterNameConflict = 601,
75
}
76

77
impl From<ArithmeticError> for ExitCode {
78
    fn from(value: ArithmeticError) -> Self {
×
79
        match value {
×
UNCOV
80
            ArithmeticError::MismatchedQubits { left: _, right: _ } => ExitCode::MismatchedQubits,
×
81
            ArithmeticError::InvalidOperation(_) => ExitCode::ArithmeticError,
×
UNCOV
82
            ArithmeticError::DuplicatedIndex => ExitCode::DuplicateIndexError,
×
UNCOV
83
            ArithmeticError::OutOfBounds(_) => ExitCode::IndexError,
×
84
        }
85
    }
×
86
}
87

88
impl From<CInputError> for ExitCode {
89
    fn from(value: CInputError) -> Self {
×
UNCOV
90
        match value {
×
91
            CInputError::AlignmentError => ExitCode::AlignmentError,
×
UNCOV
92
            CInputError::NullPointerError => ExitCode::NullPointerError,
×
UNCOV
93
            CInputError::IndexError => ExitCode::IndexError,
×
94
        }
UNCOV
95
    }
×
96
}
97

98
impl From<TargetError> for ExitCode {
99
    fn from(value: TargetError) -> Self {
12✔
100
        match value {
12✔
101
            TargetError::InvalidKey(_) => ExitCode::TargetInvalidInstKey,
4✔
102
            TargetError::AlreadyExists(_) => ExitCode::TargetInstAlreadyExists,
4✔
103
            TargetError::QargsMismatch {
104
                instruction: _,
105
                arguments: _,
UNCOV
106
            } => ExitCode::TargetQargMismatch,
×
107
            TargetError::InvalidQargsKey {
108
                instruction: _,
109
                arguments: _,
110
            } => ExitCode::TargetInvalidQargsKey,
4✔
UNCOV
111
            _ => ExitCode::TargetError,
×
112
        }
113
    }
12✔
114
}
115

116
impl From<ParameterError> for ExitCode {
UNCOV
117
    fn from(_value: ParameterError) -> Self {
×
UNCOV
118
        ExitCode::ArithmeticError
×
UNCOV
119
    }
×
120
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc