ampl parser
This commit is contained in:
@ -66,6 +66,17 @@ def _pack_tty_point(step: int, ch1: int, ch2: int) -> bytes:
|
||||
)
|
||||
|
||||
|
||||
def _pack_logdet_point(step: int, value: int) -> bytes:
|
||||
return b"".join(
|
||||
[
|
||||
_u16le(0x001A),
|
||||
_u16le(step),
|
||||
_u16le(value),
|
||||
_u16le(0x0000),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def _chunk_bytes(data: bytes, size: int = 4096) -> list[bytes]:
|
||||
return [data[idx : idx + size] for idx in range(0, len(data), size)]
|
||||
|
||||
@ -178,6 +189,26 @@ class SweepReaderTests(unittest.TestCase):
|
||||
reader.join(timeout=1.0)
|
||||
stack.close()
|
||||
|
||||
def test_parser_16_bit_x2_falls_back_to_logdet_1a00_stream(self):
|
||||
payload = bytearray()
|
||||
while len(payload) < (_PARSER_16_BIT_X2_PROBE_BYTES + 24):
|
||||
payload += _pack_logdet_point(1, 0x0F77)
|
||||
payload += _pack_logdet_point(2, 0x0FCB)
|
||||
payload += _pack_logdet_point(1, 0x0F88)
|
||||
|
||||
stack, reader, queue, stop_event, stderr = self._start_reader(bytes(payload), parser_16_bit_x2=True)
|
||||
try:
|
||||
sweep, info, aux = queue.get(timeout=2.0)
|
||||
self.assertEqual(info["signal_kind"], "bin_logdet")
|
||||
self.assertIsNone(aux)
|
||||
self.assertGreaterEqual(sweep.shape[0], 3)
|
||||
self.assertAlmostEqual(float(sweep[1]), 3959.0, places=6)
|
||||
self.assertIn("fallback -> legacy", stderr.getvalue())
|
||||
finally:
|
||||
stop_event.set()
|
||||
reader.join(timeout=1.0)
|
||||
stack.close()
|
||||
|
||||
def test_parser_16_bit_x2_probe_inconclusive_logs_hint(self):
|
||||
payload = b"\x00" * (_PARSER_16_BIT_X2_PROBE_BYTES + 128)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user