diff --git a/src/qibo/hamiltonians/abstract.py b/src/qibo/hamiltonians/abstract.py index a393ab78da..749ad0b21e 100644 --- a/src/qibo/hamiltonians/abstract.py +++ b/src/qibo/hamiltonians/abstract.py @@ -16,13 +16,9 @@ def nqubits(self): @nqubits.setter def nqubits(self, n): if not isinstance(n, int): - raise_error( - RuntimeError, f"nqubits must be an integer but is {type(n)}." - ) + raise_error(RuntimeError, f"nqubits must be an integer but is {type(n)}.") if n < 1: - raise_error( - ValueError, f"nqubits must be a positive integer but is {n}" - ) + raise_error(ValueError, f"nqubits must be a positive integer but is {n}") self._nqubits = n @abstractmethod diff --git a/src/qibo/hamiltonians/adiabatic.py b/src/qibo/hamiltonians/adiabatic.py index 951c024128..4f69be8bf1 100644 --- a/src/qibo/hamiltonians/adiabatic.py +++ b/src/qibo/hamiltonians/adiabatic.py @@ -28,7 +28,7 @@ def __new__(cls, h0, h1): else: raise_error( TypeError, - f"h0 should be a hamiltonians.Hamiltonian object but is {type(h0)}." + f"h0 should be a hamiltonians.Hamiltonian object but is {type(h0)}.", ) def __init__(self, h0, h1): # pragma: no cover diff --git a/src/qibo/hamiltonians/terms.py b/src/qibo/hamiltonians/terms.py index d2fd014b92..f1d2f7cda0 100644 --- a/src/qibo/hamiltonians/terms.py +++ b/src/qibo/hamiltonians/terms.py @@ -28,9 +28,7 @@ def __init__(self, matrix, *q): f"Invalid qubit id {qi} < 0 was given in Hamiltonian term.", ) if not isinstance(matrix, np.ndarray): - raise_error( - TypeError, f"Invalid type {type(matrix)} of symbol matrix." - ) + raise_error(TypeError, f"Invalid type {type(matrix)} of symbol matrix.") dim = int(matrix.shape[0]) if 2 ** len(q) != dim: raise_error( diff --git a/src/qibo/models/evolution.py b/src/qibo/models/evolution.py index ee4fc7df78..0a53e4917e 100644 --- a/src/qibo/models/evolution.py +++ b/src/qibo/models/evolution.py @@ -55,9 +55,7 @@ def __init__(self, hamiltonian, dt, solver="exp", callbacks=[], accelerators=Non else: ham = hamiltonian(0) if not isinstance(ham, AbstractHamiltonian): - raise TypeError( - f"Hamiltonian type {type(ham)} not understood." - ) + raise TypeError(f"Hamiltonian type {type(ham)} not understood.") self.nqubits = ham.nqubits self.backend = ham.backend if dt <= 0: diff --git a/src/qibo/models/variational.py b/src/qibo/models/variational.py index 304d8a7d44..d379cf386c 100644 --- a/src/qibo/models/variational.py +++ b/src/qibo/models/variational.py @@ -245,9 +245,7 @@ def schedule(self, t): s = self._schedule(t / self._t_max) if (abs(s) - 1) > self.ATOL: # pragma: no cover - raise_error( - ValueError, f"s cannot be greater than 1 but it is {s}." - ) + raise_error(ValueError, f"s cannot be greater than 1 but it is {s}.") return s def hamiltonian(self, t): @@ -359,9 +357,7 @@ def __init__( self.params = None # problem hamiltonian if not isinstance(hamiltonian, AbstractHamiltonian): - raise_error( - TypeError, f"Invalid Hamiltonian type {type(hamiltonian)}." - ) + raise_error(TypeError, f"Invalid Hamiltonian type {type(hamiltonian)}.") self.hamiltonian = hamiltonian self.nqubits = hamiltonian.nqubits # mixer hamiltonian (default = -sum(sigma_x)) diff --git a/src/qibo/symbols.py b/src/qibo/symbols.py index 9d27910618..9aa12a1dcc 100644 --- a/src/qibo/symbols.py +++ b/src/qibo/symbols.py @@ -63,9 +63,7 @@ def __init__(self, q, matrix=None, name="Symbol", commutative=False): ), ) ): - raise_error( - TypeError, f"Invalid type {type(matrix)} of symbol matrix." - ) + raise_error(TypeError, f"Invalid type {type(matrix)} of symbol matrix.") self.matrix = matrix def __getstate__(self):