Skip to content

Commit

Permalink
fix: pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoLiegiBastonLiegi committed Nov 29, 2024
1 parent e2d8530 commit 428aaba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 46 deletions.
48 changes: 7 additions & 41 deletions src/qibo/backends/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ def set_threads(self, nthreads): # pragma: no cover
raise_error(NotImplementedError)

@abc.abstractmethod
def cast(self, x, copy=False): # pragma: no cover
def cast(self, x, dtype=None, copy=False): # pragma: no cover
"""Cast an object as the array type of the current backend.
Args:
x: Object to cast to array.
dtype: native backend array dtype.
copy (bool): If ``True`` a copy of the object is created in memory.
"""
raise_error(NotImplementedError)
Expand All @@ -102,38 +103,6 @@ def compile(self, func): # pragma: no cover
"""
raise_error(NotImplementedError)

@abc.abstractmethod
def calculate_eigenvectors(
self, matrix, k: int = 6, hermitian: bool = True
): # pragma: no cover
"""Calculate eigenvectors of a matrix."""
raise_error(NotImplementedError)

@abc.abstractmethod
def calculate_matrix_exp(
self, a, matrix, eigenvectors=None, eigenvalues=None
): # pragma: no cover
"""Calculate matrix exponential of a matrix.
If the eigenvectors and eigenvalues are given the matrix diagonalization is
used for exponentiation.
"""
raise_error(NotImplementedError)

@abc.abstractmethod
def calculate_matrix_power(
self, matrix, power: Union[float, int], precision_singularity: float = 1e-14
): # pragma: no cover
"""Calculate the (fractional) ``power`` :math:`\\alpha` of ``matrix`` :math:`A`,
i.e. :math:`A^{\\alpha}`.
.. note::
For the ``pytorch`` backend, this method relies on a copy of the original tensor.
This may break the gradient flow. For the GPU backends (i.e. ``cupy`` and
``cuquantum``), this method falls back to CPU whenever ``power`` is not
an integer.
"""
raise_error(NotImplementedError)

@abc.abstractmethod
def calculate_jacobian_matrix(
self, circuit, parameters, initial_state=None, return_complex: bool = True
Expand Down Expand Up @@ -648,6 +617,10 @@ def execute_circuit_repeated(self, circuit, nshots, initial_state=None):
circuit._final_state = final_result
return final_result

@abc.abstractmethod
def execute_distributed_circuit(self, circuit, initial_state=None, nshots=None):
raise_error(NotImplementedError)

def calculate_symbolic(
self, state, nqubits, decimals=5, cutoff=1e-10, max_terms=20
):
Expand Down Expand Up @@ -1023,7 +996,7 @@ def sign(self, *args, **kwargs):
raise NotImplementedError

@abc.abstractmethod
def delete(a, obj, axis=None):
def delete(self, a, obj, axis=None):
"""Numpy-like delete function: https://numpy.org/doc/stable/reference/generated/numpy.delete.html"""
raise NotImplementedError

Expand Down Expand Up @@ -1350,13 +1323,6 @@ def finfo(self, *args, **kwargs):
"""Numpy-like finfo: https://numpy.org/doc/stable/reference/generated/numpy.finfo.html"""
raise NotImplementedError

@abc.abstractmethod
def device(
self,
):
"""Computation device, e.g. CPU, GPU, ..."""
raise NotImplementedError

@abc.abstractmethod
def __version__(
self,
Expand Down
5 changes: 0 additions & 5 deletions src/qibo/backends/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,6 @@ def finfo(dtype):
"""Numpy-like finfo: https://numpy.org/doc/stable/reference/generated/numpy.finfo.html"""
return np.finfo(dtype)

@staticmethod
def device():
"""Computation device, e.g. CPU, GPU, ..."""
return "CPU"

@staticmethod
def __version__():
"""Version of the backend engine."""
Expand Down

0 comments on commit 428aaba

Please sign in to comment.