diff --git a/mpqp/core/circuit.py b/mpqp/core/circuit.py index 67833aae..4dd2cb3a 100644 --- a/mpqp/core/circuit.py +++ b/mpqp/core/circuit.py @@ -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: diff --git a/mpqp/tools/display.py b/mpqp/tools/display.py index ea9540ae..a5fc61d1 100644 --- a/mpqp/tools/display.py +++ b/mpqp/tools/display.py @@ -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 diff --git a/mpqp/tools/generics.py b/mpqp/tools/generics.py index d5fafa13..321b6654 100644 --- a/mpqp/tools/generics.py +++ b/mpqp/tools/generics.py @@ -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]: