Skip to content

Commit 2219de6

Browse files
doc: error better documented
1 parent 70c4939 commit 2219de6

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

mpqp/core/instruction/measurement/pauli_string.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,16 @@ class PauliStringAtom(PauliStringMonomial):
458458
"""Represents a single Pauli operator acting on a qubit in a Pauli string.
459459
460460
Args:
461-
label: The label representing the Pauli operator (e.g., 'I', 'X', 'Y', 'Z').
461+
label: The label representing the Pauli operator.
462462
matrix: The matrix representation of the Pauli operator.
463463
464464
Raises:
465-
AttributeError: new atoms cannot be created
465+
RuntimeError: New atoms cannot be created, you should use the available
466+
ones.
466467
467468
Note:
468-
All the atoms are already initialized. Available atoms are ('I', 'X', 'Y', 'Z').
469+
All the atoms are already initialized. Available atoms are (``I``,
470+
``X``, ``Y``, ``Z``).
469471
"""
470472

471473
__is_mutable = True
@@ -476,8 +478,9 @@ def __init__(self, label: str, matrix: npt.NDArray[np.complex64]):
476478
self.matrix = matrix
477479
self.__is_mutable = False
478480
else:
479-
raise AttributeError(
480-
"New atoms cannot be created, just use the given I, X, Y and Z"
481+
raise RuntimeError(
482+
"New atoms cannot be created, just use the given `I`, `X`, `Y` "
483+
"and `Z`"
481484
)
482485

483486
@property

mpqp/execution/connection/ibm_connection.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def config_ibm_account(token: str):
2525
token: IBM Quantum API token.
2626
2727
Raises:
28-
IBMRemoteExecutionError
28+
IBMRemoteExecutionError: If the account could not be saved.
2929
"""
3030
from qiskit_ibm_provider import IBMProvider
3131

@@ -95,7 +95,8 @@ def get_IBMProvider() -> "IBMProvider":
9595
execution.
9696
9797
Raises:
98-
IBMRemoteExecutionError
98+
IBMRemoteExecutionError: In the account was not properly configured
99+
previously.
99100
100101
Example:
101102
>>> instance = get_IBMProvider()
@@ -124,13 +125,13 @@ def get_IBMProvider() -> "IBMProvider":
124125
Ibm_Provider = IBMProvider()
125126
except RequestsApiError as err:
126127
raise IBMRemoteExecutionError(
127-
"Error when instantiating IBM Provider (probably wrong token saved "
128-
"in the account).\nTrace: " + str(err)
128+
"Error when instantiating IBM Provider (probably wrong token "
129+
"saved in the account).\nTrace: " + str(err)
129130
)
130131
except AccountNotFoundError as err:
131132
raise IBMRemoteExecutionError(
132-
"Error when instantiating IBM Provider. No IBM Q account configured.\nTrace: "
133-
+ str(err)
133+
"Error when instantiating IBM Provider. No IBM Q account "
134+
"configured.\nTrace: " + str(err)
134135
)
135136
return Ibm_Provider
136137

mpqp/execution/connection/qlm_connection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def config_qlm_account(username: str, password: str, global_config: bool) -> boo
2828
outside MPQP.
2929
3030
Raises:
31-
QLMRemoteExecutionError
31+
QLMRemoteExecutionError: If the account could not be saved.
3232
"""
3333
# store the username and password in environment variables QLM_USER and QLM_PASSWD in .mpqp
3434
prev_user = get_env_variable("QLM_USER")

mpqp/execution/devices.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ def from_str_remote(name: str):
169169
name: A string containing the name of the device.
170170
171171
Raises:
172-
ValueError
172+
ValueError: If no device corresponding to the given name could be
173+
found.
173174
174175
Examples:
175176
>>> ATOSDevice.from_str_remote('NoisyQProc')

0 commit comments

Comments
 (0)