Skip to content

Commit

Permalink
fix: remove Complex class, add check for efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienCalistoTD committed Jan 28, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent cb3305e commit 839e7ac
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 3 additions & 2 deletions mpqp/core/circuit.py
Original file line number Diff line number Diff line change
@@ -358,8 +358,9 @@ def nb_qubits(self) -> int:

@nb_qubits.setter
def nb_qubits(self, nb_qubits: int):
self._user_nb_qubits = nb_qubits
self._set_nb_qubits_dynamic(nb_qubits)
if self._user_nb_qubits is None or self._user_nb_qubits != nb_qubits:
self._user_nb_qubits = nb_qubits
self._set_nb_qubits_dynamic(nb_qubits)

def _set_nb_qubits_dynamic(self, nb_qubits: int):
if not hasattr(self, "_nb_qubits") or nb_qubits != self._nb_qubits:
3 changes: 2 additions & 1 deletion mpqp/tools/display.py
Original file line number Diff line number Diff line change
@@ -5,13 +5,14 @@

import numpy as np
import numpy.typing as npt
from numbers import Complex

if TYPE_CHECKING:
from sympy import Expr, Basic

from typeguard import typechecked

from .generics import Matrix, Complex
from .generics import Matrix


@typechecked
5 changes: 0 additions & 5 deletions mpqp/tools/generics.py
Original file line number Diff line number Diff line change
@@ -63,11 +63,6 @@
"""Type alias denoting all the matrices we consider (either matrices of complex
or of ``sympy`` expressions, given to ``numpy`` as objects)"""

Complex = Union[complex, float, int]
"""Type alias representing any scalar value that can be treated as a complex number.
(either Python `complex` numbers or Real numbers (`float` or `int`).
"""


@typechecked
def flatten_generator(lst: ArbitraryNestedSequence[T]) -> Iterator[T]:

0 comments on commit 839e7ac

Please sign in to comment.