Skip to content

Commit

Permalink
test: test different extractors
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Jan 31, 2025
1 parent 338f13b commit 280b82e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/instruments/test_qrng.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
import pytest
from serial.serialutil import SerialException

from qibolab.instruments.qrng import QRNG
from qibolab.instruments.qrng import QRNG, ShaExtractor, ToeplitzExtractor

RAW_BITS = 12
"""Number of bits in each QRNG sample."""


@pytest.fixture
def qrng(mocker):
qrng = QRNG(address="/dev/ttyACM0")
def extractor():
return ShaExtractor()


@pytest.fixture
def qrng(mocker, extractor):
qrng = QRNG(address="/dev/ttyACM0", extractor=extractor)
try:
qrng.connect()
except SerialException:
Expand All @@ -22,6 +27,7 @@ def read(n):
return qrng


@pytest.mark.parametrize("extractor", [ShaExtractor(), ToeplitzExtractor()])
def test_qrng_random(qrng):
data = qrng.random(1000)
assert isinstance(data, np.ndarray)
Expand Down

0 comments on commit 280b82e

Please sign in to comment.