Skip to content

Commit 1c3d86e

Browse files
chore: review
1 parent 28d6c41 commit 1c3d86e

File tree

6 files changed

+13
-25
lines changed

6 files changed

+13
-25
lines changed

mpqp/core/circuit.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ def __init__(
173173
self.add(deepcopy(data))
174174

175175
def __eq__(self, value: object) -> bool:
176-
if not isinstance(value, QCircuit):
177-
return False
178-
return self.to_dict() == value.to_dict()
176+
return isinstance(value, type(self)) and self.to_dict() == value.to_dict()
179177

180178
def add(self, components: OneOrMany[Instruction | NoiseModel]):
181179
"""Adds a ``component`` or a list of ``component`` at the end of the

mpqp/core/instruction/barrier.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,4 @@ def to_other_language(
4343
raise NotImplementedError(f"{language} is not supported")
4444

4545
def __repr__(self):
46-
if self._dynamic:
47-
return f"{type(self).__name__}()"
48-
return f"{type(self).__name__}({self.size})"
46+
return f"{type(self).__name__}({'' if self._dynamic else self.size})"

mpqp/core/instruction/instruction.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,7 @@ def __eq__(self, value: object) -> bool:
103103
def __str__(self) -> str:
104104
from mpqp.core.circuit import QCircuit
105105

106-
connection = self.connections()
107-
circuit_size = max(connection) + 1 if len(connection) != 0 else 1
108-
circuit = QCircuit(circuit_size)
109-
circuit.add(self)
110-
return str(circuit)
106+
return str(QCircuit([self], nb_qubits=max(self.connections(), default=0) + 1))
111107

112108
def __repr__(self) -> str:
113109
from mpqp.core.instruction.gates import ControlledGate

mpqp/local_storage/load.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
"""provides utility functions for converting job and result data from the local
2-
storage format into MPQP (:class:`~mpqp.execution.job.Job` and :class:`~mpqp.execution.result.Result`) objects.
3-
It also includes functions to query and retrieve jobs and results from the database.
4-
"""
1+
"""This module provides utility functions retrieving jobs and results from local
2+
storage. In the process, they are converted to MPQP objects
3+
(:class:`~mpqp.execution.job.Job` and :class:`~mpqp.execution.result.Result`)."""
54

65
from __future__ import annotations
76

@@ -160,11 +159,11 @@ def get_all_results() -> list[Result]:
160159

161160

162161
def get_jobs_with_job(job: Job | list[Job]) -> list[Job]:
163-
"""Retrieve job(s) matching the given job(s) attributes from the database:
164-
- JobType
165-
- Circuit
166-
- Device
167-
- Measure
162+
"""Retrieve job(s) matching the given job(s) attributes from the database
163+
- ``JobType``
164+
- ``Circuit``
165+
- ``Device``
166+
- ``Measure``
168167
169168
Args:
170169
job: Job(s) to search for.

mpqp/local_storage/queries.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from mpqp.execution.connection.env_manager import get_env_variable
1313
from mpqp.execution.job import Job
1414
from mpqp.execution.result import BatchResult, Result
15-
from mpqp.local_storage.setup import ensure_local_storage, DictDB
15+
from mpqp.local_storage.setup import DictDB, ensure_local_storage
1616

1717

1818
@dataclass

mpqp/tools/maths.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ def is_hermitian(matrix: Matrix) -> bool:
102102
False
103103
104104
"""
105-
return matrix_eq(
106-
np.array(matrix).transpose().conjugate(), # pyright: ignore[reportArgumentType]
107-
matrix,
108-
)
105+
return matrix_eq(np.array(matrix).transpose().conjugate(), matrix)
109106

110107

111108
@typechecked

0 commit comments

Comments
 (0)