Skip to content

Commit

Permalink
test: added test for list_available
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoLiegiBastonLiegi committed Feb 27, 2024
1 parent f66bd12 commit 814ee43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/qibojit/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

QibojitBackend = NumbaBackend | CupyBackend | CuQuantumBackend

PLATFORMS = ("numba", "cupy", "cuquantum")


class MetaBackend:
"""Meta-backend class which takes care of loading the qibojit backends."""

PLATFORMS = ("numba", "cupy", "cuquantum")

@staticmethod
def load(platform: str) -> QibojitBackend:
"""Loads the backend.
Expand Down
7 changes: 7 additions & 0 deletions src/qibojit/tests/test_backends.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import pytest

from qibojit.backends import MetaBackend


def test_device_setter(backend):
if backend.platform == "numba":
Expand Down Expand Up @@ -114,3 +116,8 @@ def test_backend_eigh_sparse(backend, sparse_type, k):
eigvals1 = backend.to_numpy(eigvals1)
eigvals2 = backend.to_numpy(eigvals2)
backend.assert_allclose(sorted(eigvals1), sorted(eigvals2))


def test_metabackend_list_available():
available_backends = dict(zip(("numba", "cupy", "cuquantum"), (True, False, False)))
assert MetaBackend().list_available() == available_backends

0 comments on commit 814ee43

Please sign in to comment.