Skip to content

Commit

Permalink
lint improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Oct 16, 2024
1 parent f768db7 commit 32c9224
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/qibo/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,36 @@ def load(backend: str, **kwargs) -> Backend:
Args:
backend (str): Name of the backend to load.
kwargs (dict): Additional arguments for the qibo backend.
kwargs (dict): Additional arguments for the ``qibo`` backend.
Returns:
qibo.backends.abstract.Backend: The loaded backend.
:class:`qibo.backends.abstract.Backend`: Loaded backend.
"""

if backend == "numpy":
return NumpyBackend()
elif backend == "pytorch":
possible_backends = ["numpy", "pytorch", "clifford", "qulacs"]

if backend not in possible_backends:
raise_error(
ValueError,
f"Backend {backend} is not available. "
+ f"The native qibo backends are {QIBO_NATIVE_BACKENDS}.",
)

if backend == "pytorch":
return PyTorchBackend()
elif backend == "clifford":

if backend == "clifford":
engine = kwargs.pop("platform", None)
kwargs["engine"] = engine

return CliffordBackend(**kwargs)
elif backend == "qulacs":
from qibo.backends.qulacs import QulacsBackend

if backend == "qulacs":
from qibo.backends.qulacs import QulacsBackend # pylint: disable=C0415

return QulacsBackend()
else:
raise_error(
ValueError,
f"Backend {backend} is not available. The native qibo backends are {QIBO_NATIVE_BACKENDS}.",
)

return NumpyBackend()

def list_available(self) -> dict:
"""Lists all the available native qibo backends."""
Expand Down

0 comments on commit 32c9224

Please sign in to comment.